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

snowflake.snowpark.functions.timestamp_ntz_from_parts¶

snowflake.snowpark.functions.timestamp_ntz_from_parts(date_expr: Union[Column, str], time_expr: Union[Column, str]) → Column[source]¶
snowflake.snowpark.functions.timestamp_ntz_from_parts(year: Union[Column, str, int], month: Union[Column, str, int], day: Union[Column, str, int], hour: Union[Column, str, int], minute: Union[Column, str, int], second: Union[Column, str, int], nanosecond: Optional[Union[Column, str, int]] = None) → Column

Creates a timestamp from individual numeric components. The function can be used to create a timestamp from a date expression and a time expression.

Example 1:

>>> df = session.create_dataframe(
...     [[2022, 4, 1, 11, 11, 0], [2022, 3, 31, 11, 11, 0]],
...     schema=["year", "month", "day", "hour", "minute", "second"],
... )
>>> df.select(timestamp_ntz_from_parts(
...     "year", "month", "day", "hour", "minute", "second"
... ).alias("TIMESTAMP_NTZ_FROM_PARTS")).collect()
[Row(TIMESTAMP_NTZ_FROM_PARTS=datetime.datetime(2022, 4, 1, 11, 11)), Row(TIMESTAMP_NTZ_FROM_PARTS=datetime.datetime(2022, 3, 31, 11, 11))]
Copy

Example 2:

>>> df = session.create_dataframe(
...     [['2022-04-01', '11:11:00'], ['2022-03-31', '11:11:00']],
...     schema=["date", "time"]
... )
>>> df.select(
...     timestamp_ntz_from_parts(to_date("date"), to_time("time")
... ).alias("TIMESTAMP_NTZ_FROM_PARTS")).collect()
[Row(TIMESTAMP_NTZ_FROM_PARTS=datetime.datetime(2022, 4, 1, 11, 11)), Row(TIMESTAMP_NTZ_FROM_PARTS=datetime.datetime(2022, 3, 31, 11, 11))]
Copy