Site icon i2tutorials

Amazon QuickSight – formatDate

Amazon QuickSight – formatDate

 

In Amazon QuickSight, the formatDate function is used to convert a date to a string in a specified format.

Syntax

#Start#
formatDate(date, [format])
#End#

 

This function takes two arguments

 

 

Here’s an example of how to use the formatDate function to convert a date to a string in the format “yyyy-MM-dd”

Example

 

#Start#
formatDate({OrderDate}, "yyyy-MM-dd")
#End#

 

This would produce a string that represents the date in the format “yyyy-MM-dd”. For example, if the OrderDate field contained the date “2023-02-22”, the above expression would produce the string “2023-02-22”.

 

If the format parameter is omitted, the function will return the date in the default format. The default format is determined by the regional settings of the analysis or the user’s browser.

 

Example

#Start#
formatDate({OrderDate})
#End#

 

This would produce a string that represents the date in the default format for the current region.

 

Note that the formatDate function returns a string, not a date. If you need to perform date arithmetic or other operations with the result, you may need to convert it back to a date using the toDate function.

 

Exit mobile version