snowflake.snowpark.functions.timestamp_from_parts¶
- snowflake.snowpark.functions.timestamp_from_parts(date_expr: snowflake.snowpark.column.Column | str, time_expr: snowflake.snowpark.column.Column | str) Column [source]¶
- snowflake.snowpark.functions.timestamp_from_parts(year: snowflake.snowpark.column.Column | str | int, month: snowflake.snowpark.column.Column | str | int, day: snowflake.snowpark.column.Column | str | int, hour: snowflake.snowpark.column.Column | str | int, minute: snowflake.snowpark.column.Column | str | int, second: snowflake.snowpark.column.Column | str | int, nanosecond: snowflake.snowpark.column.Column | str | int | None = None, timezone: snowflake.snowpark.column.Column | str | None = None) Column
Creates a timestamp from individual numeric components. If no time zone is in effect, 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_from_parts( ... "year", "month", "day", "hour", "minute", "second" ... ).alias("TIMESTAMP_FROM_PARTS")).collect() [Row(TIMESTAMP_FROM_PARTS=datetime.datetime(2022, 4, 1, 11, 11)), Row(TIMESTAMP_FROM_PARTS=datetime.datetime(2022, 3, 31, 11, 11))]
Example 2:
>>> df = session.create_dataframe( ... [['2022-04-01', '11:11:00'], ['2022-03-31', '11:11:00']], ... schema=["date", "time"] ... ) >>> df.select( ... timestamp_from_parts(to_date("date"), to_time("time") ... ).alias("TIMESTAMP_FROM_PARTS")).collect() [Row(TIMESTAMP_FROM_PARTS=datetime.datetime(2022, 4, 1, 11, 11)), Row(TIMESTAMP_FROM_PARTS=datetime.datetime(2022, 3, 31, 11, 11))]