Amazon QuickSight – parseDate
The parseDate function in Amazon QuickSight converts a string to a date object based on the specified format.
Syntax
#Start# parseDate(expression, ['format']) #End#
This function takes two arguments:
- expression (required): the expression to convert to a date object.
- format (optional): the format of the input string. If not specified, QuickSight will attempt to automatically determine the format.
Suppose you have a dataset containing dates in the format of ‘dd-MMM-yyyy’, such as ’01-Jan-2023′. However, QuickSight does not recognize this format as a date, so you need to convert it using the parseDate function.
Assume the following dataset:
| Order ID | Order Date |
| 001 | 01-Jan-2023 |
| 002 | 15-Feb-2023 |
| 003 | 10-Mar-2023 |
To convert the Order Date field to a date object, you can use the parseDate function:
- Select the dataset that you want to create a calculated field for.
- Click on the “Add field” button.
- Enter the following expression:
Example
#Start# parseDate({Order Date}, 'dd-MMM-yyyy') #End#
This expression converts the Order Date field to a date object based on the specified format of ‘dd-MMM-yyyy’. The resulting calculated field will be a date object that QuickSight can recognize and use for date-based visualizations.
- Click “Create field” to create the calculated field.
After creating this calculated field, the Order Date field will be recognized as a date object, and you can use it for date-based visualizations and analysis. In this example, the calculated field would have the following values:
| Order ID | Order Date |
| 001 | January 1, 2023 |
| 002 | February 15, 2023 |
| 003 | March 10, 2023 |
Note that the “Order Date” column is a calculated field, and the values are not stored in the original dataset.