avery_boyd
avery_boyd

Reputation: 23

Trying to find the difference of days between two columns in two different tables using Teradata

I'm trying to work in between two columns and two tables to determine the amount of days between the two so I can exclude the data that is beyond a 7 day period between the two.

For example:

How can I calculate the days between both of the joined tables so that I can get the number of days between the two?

I tried using this in my select statement:

TIMESTAMPDIFF(DAY, fib.Purchase_Date, fid.call_date) AS difference,

But I get the following error message:

[42000][3706] [Teradata Database] [TeraJDBC 17.00.00.03] [Error 3706] [SQLState 42000] Syntax error: expected something between '(' and the 'DAY' keyword.

Upvotes: 0

Views: 78

Answers (2)

nbk
nbk

Reputation: 49373

Teradata is not mysql and has ts own syntax see manual

SELECT (fid.call_date - fib.Purchase_Date) DAY;

Upvotes: 0

GMB
GMB

Reputation: 222432

You tagged both MySQL and Teradata, but the error is for the latter.

In Teradata, we would express the date arithmetics like so:

(fib.Purchase_Date - fid.call_date) DAY

The documentation has plenty of examples.

Upvotes: 0

Related Questions