|
|
Question : Date function
|
|
IS there any way in Sybase which will give me the difference of two datetime fileds ? DateDiff truncates and is not rounding off. eg: 136 minutes should be converted to 2:16
|
Answer : Date function
|
|
There is only one way in ASE up to 11.9.x
1) DateDiff returns integer.
2) You can use DateAdd function to add the result of DateDiff to a certain date - then display only the hours, minutes and seconds (or wahtever you want)
Synax: dateadd(datepart, datediff expression, startdate)
a) you have to use convert function to get result from isql in readable format ('108' is hh:mm:ss - refer to display formats for date/time) b) the dateadd and datediff dateparts must be same c) you can coose whatever 'start date' you want, but remember, that datetime datetime starts on 1.1.1753.
Example: select convert(char(50),dateadd(ss,datediff(ss,'12/31/1999 01:01:01','1/1/2000'), '1/1/1900'),108)
|
|
|
|
|