Share via


to_timestamp_ltz

Parses the timestamp with the format to a timestamp with time zone. Returns null with invalid input.

Syntax

from pyspark.databricks.sql import functions as dbf

dbf.to_timestamp_ltz(timestamp=<timestamp>, format=<format>)

Parameters

Parameter Type Description
timestamp pyspark.sql.Column or str Input column or strings.
format pyspark.sql.Column or str, optional format to use to convert type TimestampType timestamp values.

Examples

from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('2015-04-08 12:12:12',)], ['ts'])
df.select('*', dbf.to_timestamp_ltz('ts')).show()
df = spark.createDataFrame([('2016-12-31',)], ['dt'])
df.select('*', dbf.to_timestamp_ltz(df.dt, dbf.lit('yyyy-MM-dd'))).show()
df = spark.createDataFrame(
[('2015-04-08', 'yyyy-MM-dd'), ('2025+01+09', 'yyyy+MM+dd')], ['dt', 'fmt'])
df.select('*', dbf.to_timestamp_ltz('dt', 'fmt')).show()