snowflake.snowpark.functions.interval_year_month_from_parts¶

snowflake.snowpark.functions.interval_year_month_from_parts(years: Optional[Union[Column, str]] = None, months: Optional[Union[Column, str]] = None) → Column[source]¶

Creates a year-month interval expression using with specified years and months.

This YearMonthInterval is not to be confused with the interval created by make_interval. You can define a table column to be of data type YearMonthIntervalType.

Parameters:
  • years – The number of years, positive or negative

  • months – The number of months, positive or negative

Returns:

A Column representing a year-month interval

Example:

>>> from snowflake.snowpark.functions import interval_year_month_from_parts
>>>
>>> _ = session.sql("ALTER SESSION SET FEATURE_INTERVAL_TYPES=ENABLED;").collect()
>>> df = session.create_dataframe([[1, 2]], ["years", "months"])
>>> df.select(interval_year_month_from_parts(col("years"), col("months")).alias("interval")).show()
--------------
|"INTERVAL"  |
--------------
|+1-02       |
--------------




This function or method is in private preview since 1.38.0. Type YearMonthIntervalType is currently in private preview and needs to be enabled by setting parameter `FEATURE_INTERVAL_TYPES` to `ENABLED`
Copy