fy
This function identifies the financial (or fiscal) year of the date provided. If 2 parameters (date and month year ending) are provided, then the financial year will be returned as a 4-digit numeral. Example: fy( "2022-04-01", 3 ) returns 2022. If a formatting string is provided, then the returned value is a string which contains either one year or the combination of two years. The format pattern string will be checked for pound '#' characters. Following rules apply:
If a blank date is provided, then 0 is returned in case no format pattern string is provided, otherwise a blank string is returned.
Vectorization: This function supports vectorization in the 1st function parameter.
Instead of providing a single value, you can provide a set or even a nested set which contain multiple values.
The function will then process every value and its return value contains a corresponding set containing all results.
Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter
2-3
No. | Type | Description |
---|---|---|
1 input |
date or string converted to date set |
Date Value to extract as described above. Vectorization: Put multiple values into a (nested) set. |
2 input |
numeral | Month year ending Specify the last month of the financial year (Example: Specify 3 for fiscal years ending on 31. March every year). Value must be between 1 and 12. |
Opt. 3 input |
string | Format pattern If a formatting string is provided, then the financial year will be returend as a string and not as a number. Default value: A numeric 4-digit year will be returned. |
Type | Description |
---|---|
numeral string set |
Result Numeric 4-digit year if 2 parameters are provided, or string result if 3 parameters including the format pattern are provided. set with values returnd if vectorization is applied. |
date[] = "2022-05-01";
echo( "Date is ", date[] );
patterns[] = { "FY ##", "####/##", "Q# FY ##-##" };
for (month[]=1, month[]<=12, month[]++ )
{
echo( "Year ending in ", str( date(2022,month[],1),"Mmmm" ), ": " );
print( " FY: ", fy( date[], month[] ) );
for all( patterns[], pattern[] )
{
print(" ", fy( date[], month[], pattern[] ) );
}
echo;
}
Date is 2022-05-01
Year ending in January:
FY: 2023 FY 23 2022/23 Q2 FY 22-23
Year ending in February:
FY: 2023 FY 23 2022/23 Q1 FY 22-23
Year ending in March:
FY: 2023 FY 23 2022/23 Q1 FY 22-23
Year ending in April:
FY: 2023 FY 23 2022/23 Q1 FY 22-23
Year ending in May:
FY: 2022 FY 22 2021/22 Q4 FY 21-22
Year ending in June:
FY: 2022 FY 22 2021/22 Q4 FY 21-22
Year ending in July:
FY: 2022 FY 22 2021/22 Q4 FY 21-22
Year ending in August:
FY: 2022 FY 22 2021/22 Q3 FY 21-22
Year ending in September:
FY: 2022 FY 22 2021/22 Q3 FY 21-22
Year ending in October:
FY: 2022 FY 22 2021/22 Q3 FY 21-22
Year ending in November:
FY: 2022 FY 22 2021/22 Q2 FY 21-22
Year ending in December:
FY: 2022 FY 22 2022/22 Q2 FY 22-22