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
>
Showing posts with label minus. Show all posts
Showing posts with label minus. Show all posts
Wednesday, March 21, 2012
GetDate()
G'day,
I want to display the current time minus 5 minutes. say
2004-03-29 11:43:49.123 to be 2004-03-29 11:38:49.123.
Is there any Equivalent to the DB2's CURRENT TIMESTAMP - 5 MINUTES which will display the current day say 2004-03-29 11:43:49.123 as
2004-03-29 11:38:49.123
cheers
Melbselect dateadd(mi, -5, getdate())
but: "Date and time data from January 1, 1753 through December 31, 9999, to an accuracy of one three-hundredth of a second (equivalent to 3.33 milliseconds or 0.00333 seconds)." from BOL 'datetime and smalldatetime'.|||Thanks Kaiowas
cheers
Melb
I want to display the current time minus 5 minutes. say
2004-03-29 11:43:49.123 to be 2004-03-29 11:38:49.123.
Is there any Equivalent to the DB2's CURRENT TIMESTAMP - 5 MINUTES which will display the current day say 2004-03-29 11:43:49.123 as
2004-03-29 11:38:49.123
cheers
Melbselect dateadd(mi, -5, getdate())
but: "Date and time data from January 1, 1753 through December 31, 9999, to an accuracy of one three-hundredth of a second (equivalent to 3.33 milliseconds or 0.00333 seconds)." from BOL 'datetime and smalldatetime'.|||Thanks Kaiowas
cheers
Melb
Subscribe to:
Posts (Atom)