[#BloombergLP-bdlt-CalendarUtil-nthBusinessDayOfMonthOrMaxIfValid] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlt.adoc[bdlt]::xref:BloombergLP/bdlt/CalendarUtil.adoc[CalendarUtil]::nthBusinessDayOfMonthOrMaxIfValid :relfileprefix: ../../../ :mrdocs: Load the `n`th business day of a month, or the furthest available. == Synopsis Declared in `<bdlt_calendarutil.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static int nthBusinessDayOfMonthOrMaxIfValid( xref:BloombergLP/bdlt/Date.adoc[bdlt::Date]* result, xref:BloombergLP/bdlt/Calendar.adoc[bdlt::Calendar] const& calendar, int year, int month, int n); ---- == Description Load, into the specified `result`, the date corresponding to the specified `n`th business day of the specified `month` and the specified `year` based on the specified `calendar`. A positive value of `n` indicates that counting the number of business days begins from the first calendar date of the month (inclusive), and a negative value of `n` indicates that counting the number of business days begins from the last calendar date of the month (inclusive). If there are fewer than `abs(n)` business days in the month according to the `calendar`, the business day furthest from the first date of the month is chosen if `n > 0`, and the business day furthest from the last date of the month is chosen if `n < 0`. Return 0 on success, and a non‐zero value, without modifying `*result`, if the entire month specified by `year` and `month` is not within the valid range of the `calendar` or there are no business days in the month specified by `year` and `month`. The behavior is undefined unless `n != 0`, `1 <= year <= 9999`, and `1 <= month <= 12`. == Return Value 0 on success, non‐zero on failure == Parameters [cols="1,4"] |=== | Name| Description | *result* | destination for the resulting date | *calendar* | calendar used for business‐day determination | *year* | calendar year | *month* | month of year in `[1 .. 12]` | *n* | which business day to select (non‐zero; negative counts from end) |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#