DATEADD or DATE_SUB in domo workbench

i'm trying to build logic into a MS SQL connecter to only pull the past 3 years of data,

I have tried using the DATEADD function and DATESUB but neither seem to work.

The error I get is 'wrong syntax near Current_date'

Any advice? !

Best Answers

  • MichelleH
    MichelleH Coach
    Answer ✓

    @kav_100 You will need to include the following to the end of your query:

    WHERE YEAR(`DateField`) >= YEAR(CURRENT_DATE()) - 3
    

  • GrantSmith
    GrantSmith Coach
    Answer ✓

    @kav_100

    Without seeing your SQL code,

    CURRENT_DATE doesn't exist in MS SQL. You can use GETDATE in it's place. Alternatively use CURRENT_TIMESTAMP

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**

Answers

  • MichelleH
    MichelleH Coach
    Answer ✓

    @kav_100 You will need to include the following to the end of your query:

    WHERE YEAR(`DateField`) >= YEAR(CURRENT_DATE()) - 3
    

  • GrantSmith
    GrantSmith Coach
    Answer ✓

    @kav_100

    Without seeing your SQL code,

    CURRENT_DATE doesn't exist in MS SQL. You can use GETDATE in it's place. Alternatively use CURRENT_TIMESTAMP

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**