Command Reference : String and Date Function Reference
  
 
@datenext
First possible date in next time period.
Syntax: @datenext(d, u[, step])
d: date number
u: time unit string
step: (optional) integer
Return: date number
Finds the first possible date number in the next regular frequency period following d, 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, @datenext will find the end of the period defined by the time unit.
Examples
Suppose that date1 is 730110.8 (7 PM, December 23, 1999).
Then the commands
@datenext(730110.8, "dd")
@datenext(730110.8, "mm")
yield 730111.0 (midnight, December 24, 1999) and 730119.0 (midnight, January 1, 2000), the date numbers for the beginning of the day and month following the date number 730110.8, respectively.
Similarly,
@datenext(730110.8, "hh", 3)
@datenext(730110.8, "hh", 6)
return 730110.875 (9 PM, December 23, 1999), and 730111 (midnight, December 24, 1999), which are the earliest date numbers for the subsequent 3 and 6 hour regular frequencies anchored at midnight, January 1, 2001.
If DSER is a series containing date numbers from the workfile structure
series dser1 = @datenext(dser, "mm")
gives the date number of the beginning of the next 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 = @datenext(dvec, "y")
gives the first date number in the next year for each element of the vector.
Cross-references
See also @dateceil, @datefloor, and @dateval.