Total Pageviews

2019/02/14

[Sybase] How to get the difference between two days

Problem
I have a datetime column in Sybase table, if I would like to calculate the number of second between this column and current datetime. How to do it?


How-To
Using datediff to calculate the number of seconds between two date.
The syntax and parameters are:


The SQL statement is as bellows:
SELECT DATA_TIME, datediff(ss, DATA_TIME, getdate()) as DIFF
FROM TEST;


Reference
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36271.1570/html/blocks/X47295.htm

No comments: