@dateceil |

Last possible date in a time period.

Syntax: @dateceil(d, u[, step])

d: date number, series, vector

u: time unit string

step: (optional) integer, series, vector

Return: date number, series, vector

Finds the last possible date number associated with d in the regular frequency defined by the given time unit u and optional step integer step. The regular frequency is defined relative to the basedate of midnight, January 2001.

• The valid time unit string values are: “A” or “Y” (annual), “S” (semi-annual), “Q” (quarters), “MM” (months), “WW” (weeks), “DD” (days), “B” (business days), “HH” (hours), “MI” (minutes), “SS” (seconds).

• If step is omitted, the frequency will use a step of 1, so that by default, @dateceil will find the end of the period defined by the time unit.

Examples

Suppose that d is 730110.8 (7 PM, December 23, 1999).

Then the command

@dateceil(730110.8, "dd")

gives the last date number associated with the end of December 23, 1999, yielding 730110.999 (11:59:59.999... PM, December 23, 1999).

Similarly, the command,

@dateceil(730110.8, "mm")

gives the date number associated with the end of month of December 1999 (11:59:59.999... PM, December 31, 1999) giving 730118.999.

The commands

@dateceil(730110.8, "hh", 3)

@dateceil(730110.8, "hh", 6)

return 730110.874999 (8:59:59.999... PM, December 23, 1999), and 730110.999 (11:59:59.999... PM, December 23, 1999), which are the last date numbers for 3 and 6 hour regular frequencies anchored at midnight, January 1, 2001.

If DSER is a series containing date numbers,

series dser1 = @dateceil(dser, "mm")

gives the date number of the end of the month for each observation in DSER in the workfile sample. You may use “@date” in place of DSER to obtain results using the built-in dates in the workfile structure.

If DVEC is a vector containing date numbers,

vector avec = @dateceil(dvec, "y")

gives the last date number in the year for each element of the vector.

Cross-references

See
“Dates” and
“Date Formats”for additional details on date numbers and date format strings.