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 |
sishan81
Starting Member
7 Posts |
Posted - 2010-08-03 : 05:37:57
|
I'll explain..I have a date field that contains year-month-day and an hour field which contains an hour such as 1420.how can I get the hour difference between 2010-05-02 14:20 and 2010-05-05 15:40?Thanks in advance!! |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-08-03 : 05:42:34
|
which field has the value 2010-05-05 15:40?for first part useSELECT DATEDIFF(DATEADD(n,hourfield%100,DATEADD(hh,hourfield/100,datefield)),secondfield) FROM Table ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
sishan81
Starting Member
7 Posts |
Posted - 2010-08-03 : 07:20:02
|
It says: "The datediff function requires 3 argument(s)."SELECT DATEDIFF(DATEADD(n,1540%100,DATEADD(hh,1420/100,2010-05-02)),2010-05-05) |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-08-03 : 08:44:34
|
Which datatypes are the two columns? N 56°04'39.26"E 12°55'05.63" |
 |
|
sishan81
Starting Member
7 Posts |
Posted - 2010-08-03 : 10:27:12
|
It worked! thanks a lot |
 |
|
|
|
|