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.


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 elapsed
  • DAYS BETWEEN DATETIME ( 2010 , 1 , 1 , 14 , 0 , 0 ) AND DATETIME ( 2010 , 1 , 2 , 13 , 0 , 0 ) = 0, for only 23 hours have elapsed
  • 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 elapsed

YEAR

YEAR returns the year of a date or dateTime value. The year is returned as a number in the range 1 - 9999.

Syntax

Code Block
YEAR(date | dateTime)
  • date or dateTime - The date or dateTime value of which the year must be returned.

Return type

  • integer

Examples

  • YEAR ( DATE ( 2015 , 01 , 01 ) ) equals = 2015
  • YEAR ( DATE ( 1978 , 04 , 11 ) ) equals = 1978

MONTH

MONTH returns the month of a date or dateTime value. The month is returned as a number in the range 1 - 12.

Syntax

Code Block
MONTH(date | dateTime)
  • date or dateTime - The date or dateTime value of which the month must be returned.

Return type

  • integer

Examples

  • MONTH ( DATE ( 2015 , 01 , 01 ) ) = 1
  • MONTH ( DATE ( 1978 , 04 , 11 ) ) = 4

...

This function returns the current date of the server. The date is given as base type date, formatted as dd-mm-yyyy.

Syntax

Code Block
TODAY

Return type

  • date

 

UI Text Box
typenote
The TODAY function returns a date stamp. It is only recalculated when the expression in which you use the TODAY function is reevaluated. This recalculation will not cause other expressions that use the TODAY function to be reevaluated.

 

...

This function returns the current date and time of the server. The date and time are given as base type dateTime, formatted as dd-mm-yyyy HH:mm:ss.

Syntax

Code Block
NOW

Return type

  • dateTime

 

UI Text Box
typenote
The NOW function returns a date- and timestamp. It is only recalculated when the expression in which you use the NOW function is reevaluated. This recalculation will not cause other expressions that use the NOW function to be reevaluated.

WEEKNUMBER

WEEKNUMBER returns the week number within the year of a given date or dateTime value. The week number is returned as an integer in the range 1 - 53. Week 1 for a year is the earliest seven day period starting at the first day of the week that contains at least days from that year. The first day of the week and the minimal days in that first week are defined by the region settings. In most cases the first day of the week is Monday and the minimal days in the first week is 4 (these are the values reflecting ISO 8601 and many national standards).

For example, January 1, 1998 was a Thursday. Then week 1 of 1998 starts on December 29, 1997, and ends on January 4, 1998. If, however, the first day of the week is defined as Sunday (as is the case in the US), then week 1 of 1998 starts on January 4, 1998, and ends on January 10, 1998; the first three days of 1998 then are part of week 53 of 1997.

Syntax

Code Block
WEEKNUMBER ( date | dateTime )
  • date or dateTime - The date or dateTime value of which the week number must be returned.

Return type

  • integer

Examples

  • WEEKNUMBER ( DATE ( 2015 , 01 , 01 ) ) = 1
  • WEEKNUMBER ( DATETIME ( 2014 , 12 , 28 , 0 , 0 , 0 ) ) = 1
  • WEEKNUMBER ( DATE ( 2015 , 12 , 28 ) ) = 53
  • WEEKNUMBER ( DATE ( 2016 , 01 , 02 ) ) = 53
  • WEEKNUMBER ( DATETIME ( 2016 , 01 , 04 , 0 , 0 , 0 ) ) = 1
 

DAYOFWEEK

 

DAYOFWEEK returns the number of the day within the week of a given date or dateTime value, as follows:

  • Sunday = 1
  • Monday = 2
  • Tuesday = 3
  • Wednesday = 4
  • Thursday = 5
  • Friday = 6
  • Saturday = 7

Syntax

Code Block
DAYOFWEEK( date | dateTime )
  • date or dateTime - The date or dateTime value of which the week number must be returned.

Return type

  • integer

Examples

  • DAYOFWEEK ( DATE ( 2015 , 01 , 01 ) ) = 5
  • DAYOFWEEK ( DATETIME ( 2015 , 12 , 28 , 0 , 0 , 0 ) ) = 2
  • DAYOFWEEK ( DATE ( 2016 , 01 , 02 ) ) = 7
  • DAYOFWEEK ( ? ) = ?