15 Jan 19 ·  nVector in sql ·        Bookmark ·  Report ·  More actions.. Lock comments ·  Pin thread

DATEADD(): Add or subtract from a date column in Snowflake

Adds the specified value for the specified date or time part to a date, time, or timestamp.

To Subtract 7 days from the current timestamp:

select dateadd(day,-7,current_timestamp());

To Subtract 7 months from the current timestamp:

select dateadd(month,-7,current_timestamp());

To Subtract 7 years from the current timestamp:

select dateadd(year,-7,current_timestamp());

To Subtract 7 hours from the current timestamp:

select dateadd(hour,-7,current_timestamp());

To Subtract 7 minutes from the current timestamp:

select dateadd(minute,-7,current_timestamp());

To Subtract 7 seconds from the current timestamp:

select dateadd(second,-7,current_timestamp());

You can do millisecond/nanosecond as well. You can similarly do additions to the timestamp as we did subtract, just by changing the sign.


posted on 15 Jan 19

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds