Site icon i2tutorials

Amazon QuickSight – dateDiff

Amazon QuickSight – dateDiff

 

The dateDiff function in QuickSight is used to calculate the difference between two dates. The function takes two required arguments, which are the two dates you want to compare, and an optional third argument specifying the unit of time in which you want to express the difference.

Syntax

#Start#
dateDiff(date1, date2, [period])
#End#

 

This function takes three arguments

 

 

The period parameter can take one of the following values:

For example, suppose you have a data set that includes a column for order dates and you want to create a new column that shows the number of days between the order date and the current date. You can use the dateDiff function to perform the calculation.

Example

#Start#
dateDiff(OrderDate, now(), "day")
#End#

 

This expression would calculate the difference between the OrderDate and the current date, expressed in days, and return the result in the new column. Note that the now() function is used to get the current date and time.

 

Exit mobile version