September 8, 2009 at 5:35 am
hi,
Can anyone give me the query to get the date which is 4 days back.
Say current date and time is 2009-09-08 13:34:38.327 which I can get from select getdate(). Now I want to get the datetime which is 3 days before date. So in this case 2009-09-05 13:34:38.327. How to find it through t-sql.
Ryan
//All our dreams can come true, if we have the courage to pursue them//
September 8, 2009 at 5:49 am
Use DATEADD, with a negative number of days.
select getdate(),DATEADD(day,-3,getdate())
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
September 8, 2009 at 5:52 am
Thank you very much.
Ryan
//All our dreams can come true, if we have the courage to pursue them//
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply