Home > Software engineering >  Is there an equivalent way to write DATEADD(Week,[Date]) in a Snowflake query?
Is there an equivalent way to write DATEADD(Week,[Date]) in a Snowflake query?

Time:05-19

I'm new to Snowflake and attempting to translate existing SQL based queries to a Snowflake syntax. Finding some things don't easily translate. One of them being the week parameter of the SQL DATEADD function.

How does one write DATEADD(Week,[Date]) in form of a Snowflake query? Is it possible?

CodePudding user response:

The format is:

DATEADD(Week,1,[Date])

Where the 1 signifies how many weeks you want to add

CodePudding user response:

Snowflake supports INTERVAL arithmetic:

You can use interval constants to add or subtract a period of time to/from a date, time, or timestamp. Interval constants are implemented using the INTERVAL keyword, which has the following syntax:

{ | - } INTERVAL ' [ <date_time_part> ] [ , [ <date_time_part> ] ... ]'

SELECT "Date"   INTERVAL '1 WEEK'
FROM tab
  • Related