Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Snowflake - Query Last 12 Months of Data

How would I pull the last twelve months of records without using Between? I've attempted variations of the following in my where clause :

DATEADD(YEAR,-12,O.CREATEDATE)

&

TO_DATE(O.CREATEDATE)>=DATEADD(YEAR,-12,O.CREATEDATE)

The Snowflake documentation on this SQL function appears to explain how the datadd simply changes the date. Is there a snowflake sql function that will execute this type of request?

Thank you kindly


1 Answers

You would use:

where o.createdate >= dateadd(year, -1, current_date)
like image 98
Gordon Linoff Avatar answered Sep 17 '25 22:09

Gordon Linoff