CFLib.org – Common Function Library Project

getFiscalYear([date])

Last updated March 6, 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);
	}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson