Skip to end of metadata
Go to start of metadata

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 does matter for the two dates passed in that we are calculating how much time has passed from date 1 to date 2. So, 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

Date date_1 The first date to use.

Date date_2 - The second date to use.

  • Returns

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

  • Scope

All

Code Examples
Code Snippet
# 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.
Code Snippet
# This example would create two date objects, one on the 28th of May,
# and one on the 22nd of April, both in 2018. Because the second date is
# before the first date, a negative number will be returned.
 
first = system.date.getDate(2018, 4, 28)
second = system.date.getDate(2018, 3, 22)
print system.date.daysBetween(first, second) #This will print -36
Code Snippet
# 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)

  • No labels