Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Returns the date that is days days after start. If days is a negative value then these amount of days will be deducted from start.
For the corresponding Databricks SQL function, see dateadd function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.dateadd(start=<start>, days=<days>)
Parameters
| Parameter | Type | Description |
|---|---|---|
start |
pyspark.sql.Column or str |
date column to work on. |
days |
pyspark.sql.Column or str or int |
how many days after the given date to calculate. Accepts negative value as well to calculate backwards in time. |
Returns
pyspark.sql.Column: a date after/before given number of days.
Examples
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('2015-04-08', 2,)], 'struct<dt:string,a:int>')
df.select('*', dbf.dateadd(df.dt, 1)).show()
df.select('*', dbf.dateadd('dt', 'a')).show()
df.select('*', dbf.dateadd('dt', dbf.lit(-1))).show()