Please help

Training
Enthusiast

Please help

i try to get an  interval between current day and day three month ago

this is the code:

 

LastBetDate  BETWEEN  swf_dateadd  ('day', -90,CURRENT_TIMESTAMP) AND CURRENT_TIMESTAMP);

 

but i get this error:

 

yntax error: expected something between the 'BETWEEN' keyword and the 'day' keyword.

 

what wrong?

 

 

 

 

7 REPLIES
Senior Apprentice

Re: Please help

What is swf_dateadd, a SQL UDF? Can you show the source code?

 

LastBetDate  BETWEEN  CURRENT_TIMESTAMP - INTERVAL '90' DAY AND CURRENT_TIMESTAMP  -- 90 days 
or
LastBetDate  BETWEEN  ADD_MONTHS(CURRENT_TIMESTAMP, -3) AND CURRENT_TIMESTAMP -- 3 months

Enthusiast

This is the source code

 

(L.LifeStage in  ('Inactive') AND LastBetDate BETWEEN GETDATE()-90  AND GETDATE())

Senior Apprentice

Re: This is the source code

This can't be the source code of swf_dateadd.

 

GETDATE is SQL Server syntax, in Standard SQL it's CURRENT_DATE.

Enthusiast

Re: This is the source code

Hhhh, you are jocking:)

 

111.png

Senior Apprentice

Re: This is the source code

#1 shows SQL Server syntax (due to GETDATE/CLUSTERED INDEX) and #2 should be Teradata (due to ON COMMIT).

 

I need the source code of swf_dateadd, there's no builtin function with that name in TD.

Enthusiast

Re: This is the source code

You are right

 

But if you use Ispirer Migration  Studio - on sql conversion it create this function by default - i don't know why exactly

Senior Apprentice

Re: This is the source code

First check where the function is installed: 

SELECT * FROM dbc.FunctionsV WHERE FunctionName = 'swf_dateadd'

Then do a SHOW FUNCTION.

 

Btw, are you sure about the error message?

The function might not be found by the parser, then it fails with

"Syntax error: expected something between '(' and the string 'day'", but not "and the 'day' keyword".