prevwkday(X)

Returns the date of the last weekday on or before a date-related value.

Syntax

prevwkday(X)

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:
  • date
  • date+time

For more information, see Dates and time.

Return Value

Returns the integer value (in date form) corresponding to the last weekday on or before the date-related value given as input.
Note: Weekdays are Monday through Friday, including holidays.

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 (1993) table (pub.demo.weather.hourly93), you can create a computed column that displays an integer value corresponding to the last weekday on or before the date value in the column named date:

<base table="pub.demo.weather.hourly93"/>
<willbe name="example" value="prevwkday(date)" label="Previous Weekday"/>
<colord cols="date,example"/>

For a date value of 06/16/93 (X=19930616), the result would be 06/16/93. (Since 6/16/93 is a Wednesday, which is a weekday, the same date is returned.)

For a date value of 01/24/93 (X=19930124), the result would be 01/22/93. (Since 1/24/93 is a Sunday, the date returned is the last weekday before, which is Friday, 1/22/93.)