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

snowflake.snowpark.functions.timestamp_ntz_from_parts

snowflake.snowpark.functions.timestamp_ntz_from_parts(date_expr: Union[snowflake.snowpark.column.Column, str], time_expr: Union[snowflake.snowpark.column.Column, str]) Column[source]
snowflake.snowpark.functions.timestamp_ntz_from_parts(year: Union[snowflake.snowpark.column.Column, str, int], month: Union[snowflake.snowpark.column.Column, str, int], day: Union[snowflake.snowpark.column.Column, str, int], hour: Union[snowflake.snowpark.column.Column, str, int], minute: Union[snowflake.snowpark.column.Column, str, int], second: Union[snowflake.snowpark.column.Column, str, int], nanosecond: Optional[Union[snowflake.snowpark.column.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