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.


dateDiff returns the difference in days between two date fields. If you include a value for the period, dateDiff returns the difference in the period interval, rather than in days.

dateDiff is supported for use with analyses based on SPICE data sets.


dateDiff(date1, date2[, period])


dateDiff takes two dates as arguments. Specifying a period is optional.


The first date in the comparison. A date field or a call to another function that outputs a date.


The second date in the comparison. A date field or a call to another function that outputs a date.


The period of difference that you want returned, enclosed in quotes. Valid periods are as follows:

  • YYYY: This returns the year portion of the date.

  • Q: This returns the date of the first day of the quarter that the date belongs to.

  • MM: This returns the month portion of the date.

  • DD: This returns the day portion of the date.

  • WK: This returns the week portion of the date. The week starts on Sunday in Amazon QuickSight.

  • HH: This returns the hour portion of the date.

  • MI: This returns the minute portion of the date.

  • SS: This returns the second portion of the date. (Not supported when added inside SPICE-based analyses.)

Return Type



The following example returns the difference between two dates.

dateDiff(orderDate, shipDate, "MM")

The following are the given field values.

orderDate shipdate ============================= 01/01/18 03/05/18 09/13/17 10/20/17

For these field values, the following values are returned.

2 1