Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 10548

Re: Subtract timestamps, result with fractions of seconds

$
0
0

Rather than having *_BETWEEN function for each unit of time, it would be better for HANA to have a DATEDIFF function like Microsoft SQL Server, Sybase ASE, Sybase IQ and Sybase SQL Anywhere, that takes the time unit as the first parameter.

 

With HANA, we do the following to get millisecond precision:

       ( ( extract( hour   from t2   ) * 3600 +         extract( minute from t2   ) * 60 +         extract( second from t2   ) ) -       ( extract( hour   from t1 ) * 3600 +         extract( minute from t1 ) * 60 +         extract( second from t1 ) ) )

Where t1 and t2 are timestamps, that seems to return a numeric with 3 digits of fractional sections.

 

With SPS06 promising support for scalar UDFs, at least the above or Lars' suggestion could finally be put in a user-defined function.


Viewing all articles
Browse latest Browse all 10548

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>