Link to home
Start Free TrialLog in
Avatar of venkatsr
venkatsr

asked on

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  
ASKER CERTIFIED SOLUTION
Avatar of jkotek
jkotek

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jkotek
jkotek

An in ASE 12.0 you can write your own Java function to convert the 136 to 2:16.
;-)
Avatar of venkatsr

ASKER

Thanks dude. It works for difference less then 24 hours but not more than a day. I have a situation where my calculation time extends for 3-6 days.  
Well, in case of 3+ day difference will command 'dateadd(datepart, datediff expression, '1/1/1900')' result in DATE '4/1/1900 15:06:30.3445'. I have used the convert command to get the difference into a readable format (the result was DATE '1/1/1900 22:58:59'.
You can use date display format 109 to see the full date. And in application you have to substract the 1900 years, 1 month and 1 day to get the result.
Or you can add to the 24-hrs datediff one more datediff counting days - select datediff(dy, date1, date2), convert(char(50),dateadd(ss,datediff(ss, date1, date2), '1/1/1900'),108).
Thanks buddy .It works like a charm.