user4242387
user4242387

Reputation:

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

Upvotes: 4

Views: 20423

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269923

You would use:

where o.createdate >= dateadd(year, -1, current_date)

Upvotes: 10

Related Questions