Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Filter a datetime variable to show results from previous 2 years in the SQL editor

willd9
7 - Meteor

I've input data from a table called 'Tasks' which I'm trying to filter by created_date to only show results created in the last 2 years. Here is the code I've attempted:

 

select distinct tasks.course

from tasks

where tasks.course is not null

and tasks.created_date >= dateadd(year, -2, getdate())

 

When I click 'Test Query', I get the below error message. Any ideas?

Error.png

2 REPLIES 2
DavidSkaife
13 - Pulsar

Hi @willd9 

 

As it's Oracle you could try ADD_MONTHS(SYSDATE, -24)

grazitti_sapna
17 - Castor

@willd9 , try using add_months instead of DateAdd function

 

where created_date >= add_months(sysdate, -24)

 

Sapna Gupta
Labels