Skip to main content
Version: 7.9

system.date.add*

This function is used in Python Scripting.

Description

This function is a set of functions that include:

FunctionDescription
system.date.addMillisAdd or subtract an amount of milliseconds to a given date and time.
system.date.addSecondsAdd or subtract an amount of seconds to a given date and time.
system.date.addMinutesAdd or subtract an amount of minutes to a given date and time.
system.date.addHoursAdd or subtract an amount of hours to a given date and time.
system.date.addDaysAdd or subtract an amount of days to a given date and time.
system.date.addWeeksAdd or subtract an amount of weeks to a given date and time.
system.date.addMonthsAdd or subtract an amount of months to a given date and time. This function is unique since each month can have a variable number of days. For example, if the date passed in is March 31st, and we add one month, April does not have a 31st day, so the returned date will be the proper number of months rounded down to the closest available day, in this case April 30th.
system.date.addYearsAdd or subtract an amount of years to a given date and time.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

system.date.add*(date, value)

Parameters

TypeParameterDescription
DatedateThe starting date.
IntegervalueThe number of units to add, or subtract if the value is negative.

Returns

Date - A new date object offset by the integer passed to the function.

Scope

All

Code Examples

Example #1
# This example would add two days to the date passed in.

today = system.date.now()
twoDaysFromToday = system.date.addDays(today, 2)
Example #2
# This example would subtract twenty minutes from a date object we create.
# Even though our original date starts on the 28th, it starts at midnight,
# so subtracting 20 minutes puts it at the previous day.

date = system.date.getDate(2018, 4, 28) #This would print out like Mon May 28 00:00:00 PDT 2018
print system.date.addMinutes(date, -20) #This will print Sun May 27 23:40:00 PDT 2018
Example #3
# This example can be placed on the property change script of one Vision Calendar component.
# It will then automatically set a second calendar component two weeks in advance of the first calendar's selected date.
if event.propertyName == "date":
date = event.newValue
event.source.parent.getComponent('End Date Calendar').date = system.date.addWeeks(date, 2)