Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This function calculates the period between two date or dateTime objects. This function returns the number of full periods of the specified type between two dates or dateTimes.

Valid types for period are:

  • SECONDS
  • MINUTES
  • HOURS
  • DAYS
  • WEEKS
  • MONTHS
  • YEARS

Syntax

Code Block
period BETWEEN date1 AND date2
  • period - A keyword that specifies which time unit to return. Valid units are DAYS, WEEKS, MONTHS, YEARS, HOURS, MINUTES and SECONDS.
  • date1 - The date or dateTime value that represents the start date.
  • date2 - The date or dateTime value that represents the end date.
UI Text Box
typenote
You can use the periods HOURS, MINUTES and SECONDS only if at least one of the dates is a dateTime object or expression. On the other hand, with the periods DAYS, WEEKS, MONTHS and YEARS, the time component of a datetime value is ignored.


UI Text Box
typenote

The order in which the dates are placed is irrelevant. YEARS BETWEEN date1 AND date2 = YEARS BETWEEN date2 AND date1

Return type

  • integer
UI Text Box
typenote

If you prefer a functional syntax, you can call these methods as: period_BETWEEN(date or datetime, date or datetime). For example: DAYS_BETWEEN(TODAY, UserInput.Date)

Examples

  • DAYS BETWEEN DATE( 2010 , 1 , 1 ) AND DATE( 2010 , 2 , 1 ) = 31
  • DAYS_BETWEEN ( DATE ( 2010 , 1 , 1 ) , DATE ( 2010 , 2 , 1 ) ) = 31
  • DAYS BETWEEN DATE ( 2010 , 5 , 31 ) AND DATE ( 2010 , 6 , 1 ) = 1
  • DAYS BETWEEN DATE( 2010 , 5 , 31 ) AND DATETIME ( 2010 , 6 , 1 , 12 , 0 , 0 ) = 1, since 1 day and 12 hours have elapsedbecause the time is ignored
  • DAYS BETWEEN DATETIME ( 2010 , 1 , 1 , 14 , 0 , 0 ) AND DATETIME ( 2010 , 1 , 2 , 13 , 0 , 0 ) = 0, for only 23 hours have elapsed1, because the time is ignored
  • YEARS BETWEEN DATE ( 2009 , 1 , 1 ) AND DATE ( 2010 , 1 , 1 ) = 1
  • YEARS BETWEEN DATE ( 2010 , 1 , 1 ) AND DATE ( 2020 , 1 , 1 ) = 10
  • YEARS BETWEEN DATE ( 2010 , 1 , 1 ) AND DATE ( 2011 , 5 , 1 ) = 1
  • YEARS BETWEEN DATETIME ( 2010 , 1 , 1 , 12 , 0 , 0 ) AND DATE ( 2011 , 1 , 1 ) = 0, since 364 days and 12 hours have elapsed1, because the time is ignored
Include Page
_nav_BackToTop
_nav_BackToTop

...

This function calculates the working days between two date or dateTime objects. It returns the number of full working days between two dates or dateTimes, inclusive. The default working days are Monday, Tuesday, Wednesday, Thursday and Friday. This default can be overridden by supplying a list with alternative working days.

Syntax

Code Block
WORKINGDAYS BETWEEN startDate AND endDate
WORKINGDAYS_BETWEEN ( startDate, endDate, workingDays )
  • date1 - The date or dateTime value that represents the start date.

  • date2 - The date or dateTime value that represents the end date.

  • workingDays - A list containing alternative working days. Note that the days should be specified as returned by the Date and Time functions [9.6] function, e.g. Sunday = 1, Monday = 2 etc.

UI Text Box
typenote

The order in which the dates are placed is irrelevant. YEARS BETWEEN date1 AND date2 = YEARS BETWEEN date2 AND date1. Also note that the time component of a datetime value is ignored, similar to the DAYS BETWEEN function.

Return type

  • integer

Examples

  • WORKINGDAYS BETWEEN DATE( 2015 , 1 , 1 ) AND DATE( 2015 , 2 , 1 ) = 22

  • WORKINGDAYS_BETWEEN ( DATE ( 2015 , 1 , 1 ) , DATE ( 2015 , 2 , 1 ) , [ 3, 4, 5, 6, 7 ] ) = 23 (work week Tuesday - Saterday)

  • WORKINGDAYS_BETWEEN ( DATE ( 2015 , 1 , 1 ) , DATE ( 2015 , 2 , 1 ) , [ 2, 3, 4, 5 ] ) = 17 (4 day work week Monday - Thursday)

  • WORKINGDAYS BETWEEN DATE ( 2015 , 6 , 1 ) AND DATETIME ( 2015 , 6 , 2 , 12 , 0 , 0 ) = 1, since 1 day and 12 hours have elapsedbecause the time is ignored

  • WORKINGDAYS BETWEEN DATETIME ( 2015 , 5 , 29, 12 , 0 , 0 ) AND DATE ( 2015 , 5 , 31 ) = 0, since 12 working hours have elapsed1, because the time is ignored (and 30-5 and 31-5 are Saturday and Sunday respectively)

 

Include Page
_nav_BackToTop
_nav_BackToTop

...