days(X;Y)

Returns the number of days between two date-related values.

Syntax

days(X;Y)

Input

Argument Type Description
X any numeric type A scalar value or the name of a column containing date-related values
Valid values can be of the form:
  • date
  • month
  • quarter
  • year
Y any numeric type A scalar value or the name of a column containing date-related values
Valid values can be of the form:
  • date
  • month
  • quarter
  • year

For more information, see Dates and time.

Return Value

Returns the integer value corresponding to the number of days between the two date-related values given as input.
Note: For month, quarter, or year input values, the first date of the period is used for the calculation.

If the input values are not in one of the supported formats listed above, the function returns an erroneous or illogical output.

Example

In the Hourly U.S. Weather (1990) table (pub.demo.weather.hourly90), you can create a computed column that displays an integer value corresponding to the number of days between the first day of the year and the date value in the column named date:

<base table="pub.demo.weather.hourly90"/>
<willbe name="example" value="days(firstdate(year(date));date)" label="Days Since`Beginning of Year"/>
<colord cols="date,example"/>
Note: This example uses two other date functions, year(X) and firstdate(X), in the calculation of the first argument.

For a date value of 01/03/90 (X=19900103), the result would be 2. (There are 2 days from January 1 to January 3.)

For a date value of 05/27/90 (X=19900527), the result would be 146. (There are 146 days from January 1 to May 27.)