snowflake.snowpark.functions.date_part¶
- snowflake.snowpark.functions.date_part(part: str, e: Union[Column, str]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.23.0/src/snowflake/snowpark/functions.py#L4453-L4477)¶
- Extracts the specified date or time part from a date, time, or timestamp. See DATE_PART for details. - Parameters:
- part – The time part to use for the addition. 
- e – The column expression of a date, time, or timestamp. 
 
 - Example: - >>> import datetime >>> df = session.create_dataframe([[datetime.datetime(2023, 1, 1, 1, 1, 1)]], schema=["ts_col"]) >>> df.select(date_part("year", col("ts_col")).alias("year"), date_part("epoch_second", col("ts_col")).alias("epoch_second")).show() --------------------------- |"YEAR" |"EPOCH_SECOND" | --------------------------- |2023 |1672534861 | ---------------------------