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

snowflake.snowpark.functions.time_from_parts

snowflake.snowpark.functions.time_from_parts(hour: ColumnOrName | int, minute: ColumnOrName | int, second: ColumnOrName | int, nanoseconds: ColumnOrName | int | None = None) Column[source]

Creates a time from individual numeric components.

TIME_FROM_PARTS is typically used to handle values in “normal” ranges (e.g. hours 0-23, minutes 0-59), but it also handles values from outside these ranges. This allows, for example, choosing the N-th minute in a day, which can be used to simplify some computations.

Example:

>>> df = session.create_dataframe(
...     [[11, 11, 0, 987654321], [10, 10, 0, 987654321]],
...     schema=["hour", "minute", "second", "nanoseconds"],
... )
>>> df.select(time_from_parts(
...     "hour", "minute", "second", nanoseconds="nanoseconds"
... ).alias("TIME_FROM_PARTS")).collect()
[Row(TIME_FROM_PARTS=datetime.time(11, 11, 0, 987654)), Row(TIME_FROM_PARTS=datetime.time(10, 10, 0, 987654))]
Copy