lastdate(X)

Returns the date of the last day of the period specified by a date-related value.

Syntax

lastdate(X)

Input

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

For more information, see Dates and time.

Note: Support for columns of type big integer available as of version 11.25.

Return Value

Returns the integer value (in date form) corresponding to the last day of the period specified by a date-related value given as input.

  • For a month value given as input, the date corresponding to the last day of the month is returned.
  • For a quarter value given as input, the date corresponding to the last day of the quarter is returned.
  • For a year value given as input, the date corresponding to the last day of the year is returned.

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 Monthly Statewide Seasonally Adjusted Unemployment Statistics table (pub.fin.fred2.bls.smsa), you can create a computed column that displays an integer value corresponding to the last day of the month value in the column named month:

<base table="pub.fin.fred2.bls.smsa"/>
<willbe name="example" value="lastdate(month)" label="Last Day`of Period"/>
<colord cols="month,example"/>

For a month value of 10/78 (X=197810), the result would be 10/31/78.

For a month value of 02/76 (X=197602), the result would be 02/29/76. (1976 was a leap year.)