Skip to main content

to_timestamp_ntz

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

Syntax

Python
from pyspark.databricks.sql import functions as dbf

dbf.to_timestamp_ntz(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 TimestampNTZType timestamp values.

Examples

Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('2015-04-08 12:12:12',)], ['ts'])
df.select('*', dbf.to_timestamp_ntz('ts')).show()
df = spark.createDataFrame([('2016-12-31',)], ['dt'])
df.select('*', dbf.to_timestamp_ntz(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_ntz('dt', 'fmt')).show()