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 |
|---|---|---|
|
| Input column or strings. |
|
| format to use to convert type |
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()