substract timestamp

Database
Fan

substract timestamp

Hi,

I am trying to substract two timestamp columns
All the examples I've found show this approach:

SELECT time1 - time2 DAY TO SECOND

This works so far. However when I try to do something like this:

SELECT COALESCE(time1 - time2 DAY TO SECOND, 0)

what I get is:

ERROR [42000] [Teradata][ODBC Teradata Driver][Teradata Database] Syntax error: expected something between the 'current_timestamp' keyword and the 'day' keyword.
0 records returned.
SELECT Command Failed.

Am I missing paretheses, or something else? What is the correct syntax?
2 REPLIES
Junior Contributor

Re: substract timestamp

It's both, missing paretheses and something else :-)

SELECT COALESCE((time1 - time2 DAY TO SECOND), interval '0' second)

Dieter
Fan

Re: substract timestamp

Thank you.