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.
Author |
Topic |
Brittney10
Posting Yak Master
154 Posts |
Posted - 2014-06-10 : 19:21:54
|
I'm trying to add time to the current date to create a new derived column. A couple examples are below. (23.00, 24.00, and 25.00 are my Times that need to be added to the current date. Current date = 2014-06-10 in these examples). 23.00 + current date = 2014-06-10 23:00:00.00024.00 + current date = 2014-06-11 00:00:00.00025.00 + current date = 2014-06-11 01:00:00.000etc...Also note, I'm not concatenating values, because when I concate 25.00, for example, to the current date the new column date will not be valid. Thanks for your help. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-06-10 : 19:48:45
|
dateadd(hh,25,cast(getdate() as DATE)) |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
Brittney10
Posting Yak Master
154 Posts |
Posted - 2014-06-11 : 11:25:44
|
Thanks! I got it working using this logic. I had tried using dateadd "hh" previously, but my problem was the numeric value needed converted to int. Now it's working perfectly! quote: Originally posted by James K dateadd(hh,25,cast(getdate() as DATE))
|
|
|
|
|
|
|
|