fq - Fiscal Quarter

Prev Next

Function Names

fq

Description

This function identifies the financial (or fiscal) quarter of the date provided. Example: fq( "2022-02-01", 3 ) returns 4 because February lies in the 4th quarter in the fiascal year ending in March. If a blank date is provided, then 0 is returned.

Vectorization: This function supports vectorization. Sets and nested sets containing input values are also supported.

Call as: function

Restrictions

Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter

Parameter count

2

Parameters

No.TypeDescription
1
input
date or string converted to date
numeral
set
Date or month

Specified data or month. 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.

Return value

TypeDescription
numeral
set
Result

Quarter 1..4. If vectorization is applied, then the multiple values are returned in a set

Examples

       date[] = "2022-05-01";
       echo( "Date is ", date[] );

       for (month[]=1, month[]<=12, month[]++ )
               echo( "Year ending in ", str( date(2022,month[],1),"Mmmm" ), ": ", fq( date[], month[] ) );

       echo("Vectorization exmaple:");
       echo( fq( { 31.12.2023, 01.01.2023, 06.01.2023,01.04.2024 }, 3 ) );  // Vectorization exmaple

       echo("Numeric exmaple with months specified:");
       echo( fq( { 11, 12, 1, 2, 3, 4 }, 3 ) );  // Vectorization exmaple

       echo("String exmaple with months specified:");
       echo( fq( { Mar, Apr, Dec, Jan }, 3 ) );  // Vectorization exmaple

Output

Date is 2022-05-01
Year ending in January: 2
Year ending in February: 1
Year ending in March: 1
Year ending in April: 1
Year ending in May: 4
Year ending in June: 4
Year ending in July: 4
Year ending in August: 3
Year ending in September: 3
Year ending in October: 3
Year ending in November: 2
Year ending in December: 2
Vectorization exmaple:
{3,4,4,1}
Numeric exmaple with months specified:
{3,3,4,4,4,1}
String exmaple with months specified:
{4,1,3,4}
Try it yourself: Open LIB_Function_fq.b4p in B4P_Examples.zip. Decompress before use.

See also

quarter
fy