Forum Discussion

wasonj1's avatar
wasonj1
Frequent Visitor
6 years ago
Solved

SQL Statement Variable Date Range

Hi There, I have a query that is using an SQL statement that is currently pulling data between 2018-07-01 and 2019-07-01. I want to update the SQL statement to be able to pull data between the curre...
  • VasTg's avatar
    VasTg
    6 years ago

    wasonj1 

     

    The SQL will be little bit different with Oracle  or SQL Server.

     

    Here are the examples. Replace your WHERE clause/line.

     

     

    ORACLE:
    WHERE M.Response_Date BETWEEN TRUNC(SYSDATE) AND TRUNC(ADD_MONTHS(SYSDATE,-24),'MONTH')
    
    SQL SERVER:
    WHERE M.Response_Date BETWEEN CAST(GETDATE() as DATE) AND DATEADD(MONTH,-24,CAST(GETDATE() as DATE))

     

     

    If this helps, mark it as a solution

    Kudos are nice too