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 |
mpreissner
Starting Member
21 Posts |
Posted - 2011-03-25 : 09:31:52
|
I need to combine two columns from my result set into a single column. My result set currently has three columns, DateKey(datetime), MinuteKey(int), and MetricValue(int). The DateKey value is the same for all records (i.e. 2011-03-24 00:00:00), and the MinuteKey goes in increments of 15 (0, 15, 30, 45, 60, 75, etc.) to represent each 15 minute part of the day. I want to combine my DateKey and MinuteKey columns to create a timestamp, leaving me with a two column result set, TimeStamp and MetricValue.I know I can use DATEADD to add an integer to a datetime value, but how do I get it to do the whole column? |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-03-25 : 09:36:05
|
UPDATE yourTableSET TimeStamp = DATEADD(n,MinuteKey,DateKey)JimEveryday I learn something that somebody else already knew |
 |
|
mpreissner
Starting Member
21 Posts |
Posted - 2011-03-25 : 10:38:06
|
awesome, thanks! Worked like a charm! |
 |
|
|
|
|
|
|