[#BloombergLP-bdlt-CalendarUtil-nthBusinessDayOfMonthOrMaxIfValid]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlt.adoc[bdlt]::xref:BloombergLP/bdlt/CalendarUtil.adoc[CalendarUtil]::nthBusinessDayOfMonthOrMaxIfValid
:relfileprefix: ../../../
:mrdocs:

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`&period; 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)&period; 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 &gt; 0`, and the business day furthest from the last date of the month is chosen if `n &lt; 0`&period; Return 0 on success, and a non&hyphen;zero value, without modifying `&ast;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`&period; The behavior is undefined unless `n !&equals; 0`, `1 &lt;&equals; year &lt;&equals; 9999`, and `1 &lt;&equals; month &lt;&equals; 12`&period;

== Synopsis

Declared in `&lt;bdlt&lowbar;calendarutil&period;h&gt;`

[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);
----


[.small]#Created with https://www.mrdocs.com[MrDocs]#
