15 January 2019 · npac ·       Add to Favorites   Report

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.

npac

posted on 15 January 2019

Read great educational content like this and a lot more !

Members get free exclusive access to content, new courses, and discounts. Signup for a free account to write a post / comment / upvote posts. Creating an account takes less than 5 seconds and you can start earning badges & points too

Copied