Skip to main content
Version: 7.9

system.date.*Between

This function is used in Python Scripting.

Description

This function is a set of functions that include:

FunctionDescription
system.date.millisBetweenCalculates the number of whole milliseconds between two dates.
system.date.secondsBetweenCalculates the number of whole seconds between two dates.
system.date.minutesBetweenCalculates the number of whole minutes between two dates.
system.date.hoursBetweenCalculates the number of whole hours between two dates.
system.date.daysBetweenCalculates the number of whole days between two dates. Daylight savings changes are taken into account.
system.date.weeksBetweenCalculates the number of whole weeks between two dates.
system.date.monthsBetweenCalculates the number of whole months between two dates. Daylight savings changes are taken into account.
system.date.yearsBetweenCalculates 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 restrictions.

Syntax

system.date.*Between(date_1, date_2)

Parameters

TypeParameterDescription
Datedate_1The first date to use.
Datedate_2The second date to use.

Returns

Integer - An integer that is representative of the difference between two dates.

Scope

All

Code Examples

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.
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
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)