/    /  Amazon QuickSight – addDateTime

Amazon QuickSight – addDateTime

 

The ADD_DATETIME function in Amazon QuickSight allows you to add a specified interval to a date or time value. For example, you can add days, months, years, hours, minutes, or seconds to a date or time value.

Syntax

#Start#
addDateTime(amount, period, datetime)
#End#

Arguments

  1. amount: a numerical value representing the interval to add. For example, if you want to add 5 days to a date, amount would be 5.
  2. period: a string that specifies the unit of time to add. This can be “day”, “month”, “year”, “hour”, “minute”, or “second”.

Valid periods are as follows:

  1. YYYY: This returns the year portion of the date.
  2. Q: This returns the quarter that the date belongs to (1–4).
  3. MM: This returns the month portion of the date.
  4. DD: This returns the day portion of the date.
  5. WK: This returns the week portion of the date. The week starts on Sunday in Amazon QuickSight.
  6. HH: This returns the hour portion of the date.
  7. MI: This returns the minute portion of the date.
  8. SS: This returns the second portion of the date.
  9. MS: This returns the millisecond portion of the date.

 

  1. datetime: a date or time value to which the interval will be added. This can be a date or time literal, a column in a data set, or another calculated field.

Example 

#Start#
ADD_DATETIME("2022-01-01", "1", "day")
#End#

This will add one day to the date “2022-01-01”, and the result will be “2022-01-02”.

You can use the ADD_DATETIME function to create calculated fields that you can use in visualizations or reports. For example, you could use this function to create a calculated field that shows the date one year from today. This can be useful for creating trend analyses or forecasting reports.