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

snowflake.snowpark.functions.year¶

snowflake.snowpark.functions.year(e: ColumnOrName) → Column[source]¶

Extracts the year from a date or timestamp.

Example:

>>> import datetime
>>> df = session.create_dataframe([
...     datetime.datetime.strptime("2020-05-01 13:11:20.000", "%Y-%m-%d %H:%M:%S.%f"),
...     datetime.datetime.strptime("2020-08-21 01:30:05.000", "%Y-%m-%d %H:%M:%S.%f")
... ], schema=["a"])
>>> df.select(year("a")).collect()
[Row(YEAR("A")=2020), Row(YEAR("A")=2020)]
Copy