snowflake.snowpark.functions.timestamp_from_parts¶
- snowflake.snowpark.functions.timestamp_from_parts(date_expr: ColumnOrName, time_expr: ColumnOrName) Column [source]¶
- snowflake.snowpark.functions.timestamp_from_parts(year: ColumnOrName | int, month: ColumnOrName | int, day: ColumnOrName | int, hour: ColumnOrName | int, minute: ColumnOrName | int, second: ColumnOrName | int, nanosecond: ColumnOrName | int | None = None, timezone: ColumnOrLiteralStr | 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))]