4.+Functions+-+Date+Functions
4.+Functions+-+Date+Functions
-- DATE_PART: Extracts the specified date or time part from a date, time, or
timestamp.
select *,
CURRENT_TIMESTAMP() as present_timestamp,
DATE_PART(hour, CURRENT_TIMESTAMP) as time_hours,
DATE_PART(minute, CURRENT_TIMESTAMP) as time_minutes,
DATE_PART(second, CURRENT_TIMESTAMP) as time_seconds,
DATE_PART(year, CURRENT_TIMESTAMP) as year_,
DATE_PART(quarter, CURRENT_TIMESTAMP) as quarter_,
DATE_PART(month, CURRENT_TIMESTAMP) as month_
from "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF001"."CUSTOMER";
-- DATEADD: Adds the specified value for the specified date or time part to a date,
time, or timestamp.
create table test_dates as
select *,
dateadd(year, 5, o_orderdate) as new_orderdate_year,
dateadd(month, 7, o_orderdate) as new_orderdate_month,
dateadd(quarter, 1, o_orderdate) as new_orderdate_quarter
from "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF001"."ORDERS";