CFLib.org – Common Function Library Project

getFiscalYear([date])

Last updated March 07, 2010

author

Bob Clingan

Version: 0 | Requires: CF5 | Library: DateLib

Description:
Returns the fiscal year for date. If no date is provided, year returned is based on the current timestamp.

Return Values:
Returns a number

Example:

currentFY= getFiscalYear();
currentFY= getFiscalYear(datetime=createdate(2009,10,1));

Parameters:

Name Description Required
date valid date to determine fiscal year for No

Full UDF Source:

/**
 * Returns fiscal year for a date
 * 
 * @param date      valid date to determine fiscal year for (Optional)
 * @return Returns a number 
 * @author Bob Clingan (bob@bobclingan.com) 
 * @version 0, March 6, 2010 
 */
function GetFiscalYear() {
        var datetime = now();
        var month = month(datetime);
        if (ArrayLen(Arguments) gte 1) {
        if (IsDate(Arguments[1])) {
            datetime = Arguments[1];
            month = month(datetime);
        } else datetime = Now();
        }
        if(month gte 10)
            return Year(DateAdd('yyyy', 1, datetime));
        else
           return Year(datetime);
    }

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson