snowflake.snowpark.functions.to_date¶
- snowflake.snowpark.functions.to_date(e: Union[Column, str], fmt: Union[Column, None, bool, int, float, str, bytearray, Decimal, date, datetime, time, bytes, NaTType, float64, list, tuple, dict] = None) Column [source]¶
Converts an input expression into a date.
Example:
>>> df = session.create_dataframe(['2013-05-17', '2013-05-17'], schema=['a']) >>> df.select(to_date(col('a')).as_('ans')).collect() [Row(ANS=datetime.date(2013, 5, 17)), Row(ANS=datetime.date(2013, 5, 17))] >>> df = session.create_dataframe(['2013-05-17', '2013-05-17'], schema=['a']) >>> df.select(to_date(col('a'), 'YYYY-MM-DD').as_('ans')).collect() [Row(ANS=datetime.date(2013, 5, 17)), Row(ANS=datetime.date(2013, 5, 17))] >>> df = session.create_dataframe(['31536000000000', '71536004000000'], schema=['a']) >>> df.select(to_date(col('a')).as_('ans')).collect() [Row(ANS=datetime.date(1971, 1, 1)), Row(ANS=datetime.date(1972, 4, 7))]