Wednesday, March 21, 2012

getdate() - 5 hrs

How can i return the getdate value minus 5 hrs
So if getdate is 2005/09/07 7am .. Id like to output to be 2005/09/07 2am
ThanksSELECT DATEADD(hh, -5, GETDATE())
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Hassan" <hassanboy@.hotmail.com> wrote in message
news:%23gQMybEtFHA.1252@.TK2MSFTNGP09.phx.gbl...
How can i return the getdate value minus 5 hrs
So if getdate is 2005/09/07 7am .. Id like to output to be 2005/09/07 2am
Thanks|||SELECT DATEADD(hour, -5, CURRENT_TIMESTAMP)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Hassan" <hassanboy@.hotmail.com> wrote in message news:%23gQMybEtFHA.1252@.TK2MSFTNGP09.phx.
gbl...
> How can i return the getdate value minus 5 hrs
> So if getdate is 2005/09/07 7am .. Id like to output to be 2005/09/07 2am
> Thanks
>|||Or
SELECT CONVERT(CHAR(10),GETDATE(),121)+
REVERSE(LEFT(STUFF(REVERSE(
CONVERT(varchar,getdate(),9)),3,4,SPACE(
0)),11))
"Hassan" <hassanboy@.hotmail.com> wrote in message
news:%23gQMybEtFHA.1252@.TK2MSFTNGP09.phx.gbl...
> How can i return the getdate value minus 5 hrs
> So if getdate is 2005/09/07 7am .. Id like to output to be 2005/09/07 2am
> Thanks
>

No comments:

Post a Comment