--- title: "system.date.*Between" description: "Calculates the amount of time between two dates." --- # system.date.*Between > Calculates the amount of time between two dates. This function is used in **Python Scripting**. ## Description This function is a set of functions that include: | Function | Description | | -------- | ----------- | |system.date.millisBetween |Calculates the number of whole milliseconds between two dates. | |system.date.secondsBetween |Calculates the number of whole seconds between two dates. | |system.date.minutesBetween |Calculates the number of whole minutes between two dates. | |system.date.hoursBetween |Calculates the number of whole hours between two dates. | |system.date.daysBetween |Calculates the number of whole days between two dates. Daylight savings changes are taken into account. | |system.date.weeksBetween |Calculates the number of whole weeks between two dates. | |system.date.monthsBetween |Calculates the number of whole months between two dates. Daylight savings changes are taken into account.| |system.date.yearsBetween |Calculates the number of whole years between two dates. Daylight savings changes are taken into account. | Order matters when passing in the two dates required by this function. system.date.*Between will subtract the first date from the second date, meaning if date 2 is further in time than date 1, then a positive amount of time has passed. If date 2 is backwards in time from date 1, then a negative amount of time has passed. ## 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.*Between(date_1, date_2)` ### Parameters Type | Parameter | Description ------- | ------- | ------- Date | `date_1` | The first date to use. Date | `date_2` | The second date to use. ### Returns **Integer** - An integer that is representative of the difference between two dates. ### Scope Gateway, Vision Client, Perspective Session ## Code Examples ```python title="Example #1" # This example would grab the current time, and add 119 minutes to it, then calculate the number # of hours between the two dates. first = system.date.now() second = system.date.addMinutes(first, 119) print system.date.hoursBetween(first, second) # This would print 1 since it is only 1 whole hour. ``` ```python title="Example #2" # This example would create two date objects, one on the 28th of May, # and one on the 22nd of April, both in 2020. Because the second date is # before the first date, a negative number will be returned. first = system.date.getDate(2020, 4, 28) second = system.date.getDate(2020, 3, 22) print system.date.daysBetween(first, second) # This will print -36 ``` ```python title="Example #3" # This example can be placed on the action performed event of a button. # It will then grab the week difference of two calendar components, # and enter the value returned into a numeric text field. first = event.source.parent.getComponent('Start Date Calendar').date second = event.source.parent.getComponent('End Date Calendar').date event.source.parent.getComponent('Numeric Text Field').intValue = system.date.weeksBetween(first, second) ```