TIMESTAMPADD

This function adds a specified date/time interval to given date field or expression. The interval timeframe can be changed depending on the fields need.

TIMESTAMPADD( <Interval>, <Interval_Value>, <Field or Timestamp>)Description
  • Interval: The timeframe used to measure the time difference between each timestamp/date.
    • SQL_TSI_FRAC_SECOND: Difference returned in Milliseconds
    • SQL_TSI_SECOND: Difference returned in Seconds
    • SQL_TSI_MINUTE: Difference returned in Minutes
    • SQL_TSI_HOUR: Difference returned in Hours
    • SQL_TSI_DAY: Difference returned in Days
    • SQL_TSI_WEEK: Difference returned in Weeks
    • SQL_TSI_MONTH: Difference returned in Months
    • SQL_TSI_QUARTER: Difference returned in Quarters
    • SQL_TSI_YEAR: Difference returned in Years
  • Interval_Value: The amount of time to add, dependant on which Interval Timeframe has been selected. (eg Hours, Days, Weeks).
  • Field or Timestamp: The Timestamp (Date / Time) to be used in the Calculation.

Example: Create a field which calculates a transaction’s follow up date, 14 days after the original Transaction Order date was made.

TIMESTAMPADD( SQL_TSI_DAY, 14 , [Transaction.Order Date])

Result:

  • Returns a follow up date of 22/02/2016 for an order date of 08/02/2016
  • Returns a follow up date of 05/11/2016 for an order date of 22/10/2016
  • Returns a follow up date of 20/01/2015 for an order date of 06/01/2015
  • Returns a follow up date of 03/08/2016 for an order date of 17/08/2016