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 |
|
joe8079
Posting Yak Master
127 Posts |
Posted - 2011-11-25 : 13:16:04
|
| Hello,I have two columns and i'm trying to calculate the difference between the two time frames in hours:minutes:seconds, but its not coming out correctly: column 1 column 218:24:00 - 17:00:00I would like the new column to say 1 HR 24 Minute Difference |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-11-25 : 13:27:33
|
| col2-col1 will give the time diferenceconvert(varchar(20),datepart(hh,col2-col1)) + ' hours ' + convert(varchar(20),datepart(mi,col2-col1)) + 'minute difference'Do you really want to do this formatting in sql though.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
joe8079
Posting Yak Master
127 Posts |
Posted - 2011-11-25 : 13:54:16
|
| awesome, thanks that works great |
 |
|
|
vikki.seth
Yak Posting Veteran
66 Posts |
Posted - 2011-11-25 : 14:41:16
|
| you also try with datediff() function.http://msdn.microsoft.com/en-us/library/ms189794.aspx |
 |
|
|
joe8079
Posting Yak Master
127 Posts |
Posted - 2011-11-25 : 16:00:29
|
| Thanks, i'll give that a shot as well. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|