Date parameter

Dates parameters are replaced by date values in your queries. They are always used in pairs, defining the start and the end of a period of time.

Date Parameter Settings

When creating a dates parameter, there are a few settings to be defined:

Values

Define the dates that will be available for selection in the control UI. The calendar will be limited to the dates defined in this setting.

Naming

  • Display name: The name that will appear in the control UI.

  • SQL name(s): The name to be used in the SQL query to be replaced by the starting and ending date of the selected period.

Using Date Parameters in your SQL Query

Once the parameter has been created, it should be added manually (using its SQL names) to one or more of your SQL Query data sources, like:

SELECT * FROM carto-demo-data.demo_tables.spain_earthquakes
WHERE time >= {{date_from}} AND time <= {{date_to}}

After adding the parameter to your SQL query data sources, the control UI will appear in the right-side panel, allowing to define the min and max pair of date values:

Last updated