--- title: "system.date.add*" description: "Add or subtract an amount of time to a given date." --- # system.date.add* > Add or subtract an amount of time to a given date. This function is used in **Python Scripting**. ## Description This function is a set of functions that include: | Function | Description | | --- | --- | |system.date.addMillis |Add or subtract an amount of milliseconds to a given date and time. | |system.date.addSeconds |Add or subtract an amount of seconds to a given date and time. | |system.date.addMinutes |Add or subtract an amount of minutes to a given date and time. | |system.date.addHours |Add or subtract an amount of hours to a given date and time. | |system.date.addDays |Add or subtract an amount of days to a given date and time. | |system.date.addWeeks |Add or subtract an amount of weeks to a given date and time. | |system.date.addMonths |Add 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.addYears |Add or subtract an amount of years to a given date and time. | ## Client Permission Restrictions This scripting function has no [Client Permission](ignition-modules\vision\vision-project-properties\vision-project-properties.md#vision-permissions-properties) restrictions. ## Syntax `system.date.add*(date, value)` ### Parameters Type | Parameter | Description ------- | ------- | ------- Date | `date` | The starting date. Integer | `value` | The number of units to add or subtract. Positive values will add specified units, and negative values will subtracts specified units. ### Returns **Date** - A new date object offset by the integer passed to the function. ### Scope Gateway, Vision Client, Perspective Session ## Code Examples ```python title="Example #1" # This example adds two days to the date passed in. today = system.date.now() twoDaysFromToday = system.date.addDays(today, 2) ``` ```python title="Example #2" # This example subtracts 20 minutes from the date object created. # Notice that although our original date starts at midnight, # so subtracting 20 minutes puts it at the previous day. # Set your date as Thu Jun 25 00:00:00 PDT 2020 date = system.date.getDate(2020, 5, 25) # Print the date adjustment of 20 minutes prior: Wed Jun 24 23:40:00 PDT 2020 print system.date.addMinutes(date, -20) ``` ```python title="Example #3" # This example works as a property change script of a Vision Calendar component. # It sets a second Calendar component two weeks in advance of the first Calendar component. if event.propertyName == "date": date = event.newValue event.source.parent.getComponent('End Date Calendar').date = system.date.addWeeks(date, 2) ```