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 2012 Forums
 Transact-SQL (2012)
 dateadd

Author  Topic 

wided
Posting Yak Master

218 Posts

Posted - 2015-02-16 : 09:41:22
there is a finction that allows me to directly add hours, minutes, seconds to my initial date: example:

date1 = '2014-05-16 06: 56: 23,000'

I want to add on that date: 12:22:06

(12 hours 22 minutes 6 seconds)

thanks

mhorseman
Starting Member

44 Posts

Posted - 2015-02-16 : 10:02:01
declare @date1 datetime
set @date1 = '2014-05-16 06: 56: 23.000'

select dateadd(ss,6,dateadd(mi,22,(DATEADD(hh,12,@date1))))

Mark
Go to Top of Page

wided
Posting Yak Master

218 Posts

Posted - 2015-02-16 : 10:41:08
thanks mark
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2015-02-23 : 08:10:51
or

select @date1+'12:22:06'

Madhivanan

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

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2015-02-23 : 15:32:39
select dateadd(ss, datediff(ss, 0, '12:22:06'), @Date1)



Those who will not reason, are bigots, those who cannot, are fools, and those who dare not, are slaves. -Lord Byron, poet (1788-1824)
Go to Top of Page
   

- Advertisement -