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 |
|
usa_vn75
Starting Member
1 Post |
Posted - 2004-12-31 : 08:20:24
|
| Hi there,I am trying to return the total number of seconds crossed between two specified dates. However, these specified dates are stored in total number of seconds.Fx (This is what it looks like in our db): Opendate: 1076632911Closedate: 1077740328 What I like to do is to be able to return the difference in seconds for these 2 dates.I went to Book Onlines and I found this function:DATEDIFF ( datepart , startdate , enddate ) This function returns the number of date and time boundaries crossed between two specified dates. So I thought I could apply it to find the total of seconds between 2 specified dates.So I attempt to do this: Datediff (s, opendate, closedate).What I expect to see in the result is: 1107417 as the difference in total seconds (1077740328 - 1076632911)Insteads I got the error message stating that there is an overflow in the integer....Any idea is greatly appreciated.AD. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-12-31 : 08:35:11
|
so if you have the dates already in seconds what's wrong with doing ClosedDate - OpenDate = 1077740328 - 1076632911 = 1107417 for using datediff, you need to know from which date the seconds started counting.you could do datediff(s, dateadd(s, Closedate, 19000101), dateadd(s, Opendate, 19000101)) but that seems like overkill...Go with the flow & have fun! Else fight the flow |
 |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2004-12-31 : 12:06:16
|
| Yes, just do the subtraction that spirit1 shows. DATEDIFF is specifically designed for use with SQL Server datetime or smalldatetime data types.---------------------------------------------------------------------------------Infoneering: Information Technology solutions engineered to professional standards. |
 |
|
|
|
|
|
|
|