Data Platform/Systems/Superset/Date functions
Appearance
The date function documentation is licensed by Apache Software Foundation (ASF) under the Apache License, Version 2.0. Use these functions when configuring advanced time ranges in Superset charts.
DATETIME
Return to specific datetime.
Syntax
datetime([string])
Example
datetime("2020-03-01 12:00:00") datetime("now") datetime("last year")
DATEADD
Moves the given set of dates by a specified interval.
Syntax
dateadd([datetime], [integer], [dateunit]) dateunit = (year | quarter | month | week | day | hour | minute | second)
Example
dateadd(datetime("today"), -13, day) dateadd(datetime("2020-03-01"), 2, day)
DATETRUNC
Truncates the specified date to the accuracy specified by the date unit.
Syntax
datetrunc([datetime], [dateunit]) dateunit = (year | month | week)
Example
datetrunc(datetime("2020-03-01"), week) datetrunc(datetime("2020-03-01"), month)
LASTDAY
Get the last date by the date unit.
Syntax
lastday([datetime], [dateunit]) dateunit = (year | month | week)
Example
lastday(datetime("today"), month)
HOLIDAY
Get the specify date for the holiday
Syntax
holiday([string]) holiday([holiday string], [datetime]) holiday([holiday string], [datetime], [country name])
Example
holiday("new year") holiday("christmas", datetime("2019")) holiday("christmas", dateadd(datetime("2019"), 1, year)) holiday("christmas", datetime("2 years ago")) holiday("Easter Monday", datetime("2019"), "UK")