snowflake.snowpark.functions.date_format¶
- snowflake.snowpark.functions.date_format(c: Union[Column, str], fmt: Union[Column, str]) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/functions.py#L3657-L3695)¶
Converts an input expression into the corresponding date in the specified date format.
- Example::
>>> df = session.create_dataframe([("2023-10-10",), ("2022-05-15",), ("invalid",)], schema=['date']) >>> df.select(date_format('date', 'YYYY/MM/DD').as_('formatted_date')).show() -------------------- |"FORMATTED_DATE" | -------------------- |2023/10/10 | |2022/05/15 | |NULL | --------------------
- Example::
>>> df = session.create_dataframe([("2023-10-10 15:30:00",), ("2022-05-15 10:45:00",)], schema=['timestamp']) >>> df.select(date_format('timestamp', 'YYYY/MM/DD HH:mi:ss').as_('formatted_ts')).show() ----------------------- |"FORMATTED_TS" | ----------------------- |2023/10/10 15:30:00 | |2022/05/15 10:45:00 | -----------------------