@datefloor |

First possible date in a time period.

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

d: date number, series, vector

u: time unit string

step: (optional) integer, series, vector

Return: date number, series, vector

Finds the first 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

@datefloor(730110.8, "dd")

gives the first date number associated with the end of December 23, 1999, yielding 730110.0 (midnight, December 23, 1999).

Similarly, the command

@datefloor(730110.8, "mm")

returns 730088.0 (midnight, December 1, 1999), the date number for the beginning of the associated with 730110.8.

The commands

@datefloor(730110.8, "hh", 6)

@datefloor(730110.8, "hh", 12)

return 730110.75 (6 PM, December 23, 1999), and 730110.5 (Noon, December 23, 1999), which are the earliest date numbers for 6 and 12 hour regular frequencies anchored at Midnight, January 1, 2001.

If DSER is a series containing date numbers,

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

gives the date number of the beginning 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 = @datefloor(dvec, "y")

gives the first 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.