DateTimeAdd |
Top Previous Next |
×V4.2.1Ø
Syntax - DateTimeAdd <variable name> <DateValue> <NumberOfUnits> {"DAYS"|"WEEKS"|"MONTHS"|"YEARS" | "WORKDAYS" |"HOURS" | "MINUTES" | "SECONDS"} Where: <variable name> is the user defined name that is assigned to the variable. <DateValue> is a literal string that represents a valid date or a variable that contains a date. <NumberOfUnits> is an integer or a variable that contains an integer.
Description: Similar to the DateAdd command, this command is used to create a date by adding (or subtracting) the <NumberOfUnits> specified days, workdays, weeks, months or years to the date component of the <DateValue>. However, the DateTimeAdd command can also process time including hours, minutes, and seconds. The new date is stored as the <variable name>. To subtract, use a negative value for the <NumberOfUnits>. When using the WORKDAYS option, EMUE adds or subtracts days while excluding weekends. If the starting <DateValue> has both a date and a time component, then the resulting value will include both a date and a time. If the <Date Value> has only a time component, then the unit being added or subtracted must be Hours, Minutes, or Seconds and the resulting value will be a time only. If the <DateValue> has only a date component, then the time is assumed to be 12:00:00 AM. If Hours, Minutes, or Seconds are being added to the starting date, then the resulting value will have both a date and a time component. Otherwise, the resulting value will remain only a date component. Whenever a time component is provided, it will be in an HH:mm:ss format using a 24 hour clock. Dates are provided in an MM/dd/yyyy format.
Note: This command accommodates the different lengths of the months and leap years when computing the new date.
Sample 1: The following statement uses DateTimeAdd to add 3 hours to the date of “05/20/2012 11:45 a.m.”. The resulting date of “05/20/2012 14:45:00” is stored as NewDate. DateTimeAdd NewDate "5/20/2012 11:45 AM" 3 "HOURS"
Sample 2: The following statement uses DateTimeAdd to subtract 3 days from the March 10, 2013. The resulting date of “03/07/2013” is stored as NewDate. DateTimeAdd NewDate "03/10/13" -3 "DAYS"
Sample 3: The following statement uses DateTimeAdd to add 15 minutes to the variable that stores the time 3:50 PM. The resulting time, using a 24-hour clock, of "16:05:00" is stored as EndTime. DateTimeAdd EndTime StartTime 15 "MINUTES"
|