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:
- Column 1 Table 1: has a date of 01-01-2023
- Column 2 Table 2: has a date of 01-07-2023
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.
CodePudding user response:
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.
CodePudding user response:
Teradata is not mysql and has ts own syntax see manual
SELECT (fid.call_date - fib.Purchase_Date) DAY;