TIME STAMP Difference in DAYS

General
Enthusiast

TIME STAMP Difference in DAYS

Hi,

We are doing a code migration from a open source database to TD. 

There is a code which subtracts two timestamp field like the one below

SELECT (TIMESTAMP '2012-10-14 23:59:00' - TIMESTAMP '2012-10-14 00:00:00') DAY(4);

For the above the result in TD would be 0 as the start and end datetime is on the same day, however the code in the source database give 1. 

Select (CAST(li.enddatetime AS TIMESTAMP(0)) - CAST(li.Startdatetime AS TIMESTAMP(0))) DAY(4)

Appreciate if someone could help me here

Thanks!

From Table X;

3 REPLIES
Enthusiast

Re: TIME STAMP Difference in DAYS

Got the solution for this!

Junior Contributor

Re: TIME STAMP Difference in DAYS

Great you got the solution, but could you share it, too?

And could you mention which DBMS returns one day if it's actually less than one?

What does it return for 

SELECT (TIMESTAMP '2012-10-15 00:00:01' - TIMESTAMP '2012-10-14 23:59:59') DAY(4);

Re: TIME STAMP Difference in DAYS

yes please share, it will be a great help