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 |
|
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2007-03-01 : 11:55:49
|
| I'd like to take two DateTimes, subtract them and insert the result as HH:MM:SS,I think you use datediff but I'm not clear on the datediff formatting to get back HH:MM:SS...Thanks for your help!--PhB |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2007-03-01 : 13:26:54
|
| Hhmmmmm, Two things with this. 1: If you change the date @s to '2001-12-30 11:59:25', the query still results in the same time amount. It should be greater, no?2: The time value result from above has to be a varchar?Thank you!--PhB |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2007-03-01 : 13:39:57
|
quote: Originally posted by phrankbooth Hhmmmmm, Two things with this. 1: If you change the date @s to '2001-12-30 11:59:25', the query still results in the same time amount. It should be greater, no?
No, you are only displaying the time component with the CONVERT Function. Are you looking to add 24 hours, so that you include the Date component? If so, you'll need to do more workquote: 2: The time value result from above has to be a varchar?
Yesquote: Thank you!
You're welcome--PhB[/quote]Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-03-01 : 14:48:16
|
| phrankbooth --this page may help you out a little:http://weblogs.sqlteam.com/jeffs/archive/2007/01/02/56079.aspxLots of datetime functions to use and some that help you work with timespans.Remember that if you substract two times, the "offset" number of days is from 1/1/1900.so, if I substract 5:00PM from 10:00PM, the result is:1/1/1900 5:00AMwhich is five hours into day 0.if you substract 6:00PM from 5:00PM, the result is:12/31/1899 11:00PM which is basically -1 hours from 1/1/1900 12:00:00 AM. Write some simple SQL statements and play around with this until you get the idea.- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2007-03-01 : 21:10:55
|
| Ooooh, juicy page! Uhthangyuhverahmush.--PhB |
 |
|
|
|
|
|
|
|