months(X;Y)
Returns the number of months between two date-related values.
Syntax
months(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:
|
Y |
any numeric type | A scalar value or the name of a column
containing date-related values Valid values can be of the form:
|
For more information, see Dates and time.
Return Value
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 months 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="months(firstdate(year(date));date)" label="Months Since`Beginning of Year"/> <colord cols="date,example"/>
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 0. (There
are 0 months from January 1 to January 3.)
For a date value of 05/27/90
(X
=19900527), the result would be 4. (There
are 4 months from January 1 to May 27.)