You are viewing documentation about an older version (1.12.1). View latest version

snowflake.snowpark.functions.date_format

snowflake.snowpark.functions.date_format(c: Union[Column, str], fmt: Union[Column, str]) Column[source]

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              |
--------------------
Copy
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  |
-----------------------
Copy