Amazon QuickSight
User Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

formatDate

formatDate formats a date using a pattern you specify. When you are preparing data, you can use formatDate to reformat the date or specify a different time zone. To reformat a date in an analysis, you choose the format option from the context menu on the date field.

Note

In SPICE, you can use this function in a calculated field that's added to a data set, but not in a calculated field that's added to an analysis.

Syntax

formatDate(date, ['format'], ['timezone'])

Arguments

date

A date field or a call to another function that outputs a date.

format

(Optional) A string containing the format pattern to apply. This argument accepts the format patterns specified in Supported Date Formats.

If you don't specify a format, this string defaults to yyyy-MM-ddTkk:mm:ss:SSS.

time_zone

(Optional) A string representing an IANA time zone. The default time zone is UTC.

Return Type

String

Example

The following example formats a UTC date and displays using a specific time zone.

formatDate(orderDate, 'dd MMM yyyy', 'America/Los_Angeles')

The following are the given field values.

order date ========= 2012-12-14T00:00:00.000Z 2013-12-29T00:00:00.000Z 2012-11-15T00:00:00.000Z

For these field values, the following values are returned.

13 Dec 2012 28 Dec 2013 14 Nov 2012