Adding or subtracting time from a date-time value
Problem
You need to add or subtract time (seconds, minutes, hours, days) from a date-time value expressed as YYYYMMDD or YYYYMMDDHHMMSS.
Solution
Use the add_to_date function in a CALCUL question.
Discussion
CallWeb stores dates as YYYYMMDD values and date-time as YYYYMMDDHHMMSS values. For example, $contexte{date} contains the current date formatted as YYYYMMDD (currently 20240328) and $contexte{dateheure} contains the current date and time formatted as YYYYMMDDHHMMSS (currently 20240328091349). While comparisons are easy, other manipulations of such values are not. Adding one day to 20091231 returns 20100101, for example. The add_to_date function helps with date and date-time calculations.
Here is the general syntax of the add_to_date function:
ADATE2 = add_to_date($ADATE1,value,type_of_offset)
where
So, add_to_date(20091231,1,"DAY") adds one day to New Year's Eve 2009 while add_to_date(20091231235959,1,"SECOND") moves from 2009 to 2010. Nevative values subtract from the stated date.
The result returned by add_to_date has the same length as the input value. Thus, adding less than one day to a YYYYMMDD value will return the same date value.