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 2005 Forums
 Transact-SQL (2005)
 Subtracting hours off Current Time

Author  Topic 

markinnes74
Starting Member

2 Posts

Posted - 2009-08-24 : 09:03:06
Hi,

I am trying select the current system time in just hours and minutes then subtract 5 hours from this.

I am using select CONVERT(nvarchar(5), CURRENT_TIMESTAMP ,8) to get the current time without date but when trying to subtract it falls over.

Any idea's please?

thanks

Mark

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-08-24 : 09:08:26
SELECT CONVERT(NVARCHAR(5), DATEADD(HOUR,-5,CURRENT_TIMESTAMP) ,8)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2009-08-24 : 09:08:35
select convert(varchar(5), DATEADD(hh, -5, getdate()), 114)
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-08-24 : 09:11:09
select convert(nvarchar(5),dateadd(hour,-5,CURRENT_TIMESTAMP) ,8)


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-08-24 : 09:11:45
Argh!
Double sniped



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

markinnes74
Starting Member

2 Posts

Posted - 2009-08-24 : 10:37:49
thank you. they worked.
Go to Top of Page
   

- Advertisement -