Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 substracting minutes from datetime

Author  Topic 

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2002-07-11 : 02:26:42
hi,
can anyone tell me how to substract minutes,hours,weeks from a datetime value?
thnxs
harsh

nr
SQLTeam MVY

12543 Posts

Posted - 2002-07-11 : 02:36:19
dateadd function?

or for anything day/time based
select @d = @d - 'dd jan 1900 hh:mm:ss'

e.g. to subtract 1 day 5 hrs
select @d = @d - '02 jan 1900 05:00:00'
or
select @d = dateadd(hh,-5,dateadd(dd,-1,@d))


==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -