I have datetime field with 24 hour format . I want to format that field to 12 hour format with am pm .
Example I have to show date field = 12-Jul-2025 01:10:10 AM
I am getting error while using formatDate function in calculated field . Any idea how to get this format .
To format a datetime field in Quick Sight to 12-hour format with AM/PM, you’may need to modify your formatDate function slightly. Please try the syntax below:
I think there are nuances related to formatdate function as mentioned in the documentation
Your datasource has a role to play. For example I tried the 12 hour format on a datetime field for my mySQL datasource and fails with the same error as you get.
To convert the ISO 8601 date format (example - > 2024-08-15T03:00:59.00Z) to 12-hour format in Amazon Quick Sight, you can use the parseDate() function in a calculated field. See here for referecne
For timestamps with ‘T’ and ‘Z’ characters like yours, you need to handle these special characters by enclosing them in single apostrophes.
You can create a calculated field using this formula:
After parsing the date correctly, you can format it to display in 12-hour format using the formatDate() function with the appropriate tokens. Reference
To get 12-hour format, use the ‘h’ or ‘hh’ token for hours and ‘a’ for am/pm indicator.