getCurrentFinYear(mask[, date])
Last updated May 26, 2003
Version: 1 | Requires: CF5 | Library: DateLib
Description:
Calculates the current financial year and passes it back in the format specified. Pass a format mask to this function using "y1" to denote the first half year and "y2" for the second. For instance to request the financial year returned in the format: "2002/2003" use: getCurrentFinYear("y1/y2");
Return Values:
Returns a string.
Example:
<cfoutput>
#getCurrentFinYear("y1/y2")#
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
mask | Formats result using y1 and y2. | Yes |
date | Date to use. Defaults to now(). | No |
Full UDF Source:
/**
* Returns the current two-part financial year in a specified format.
*
* @param mask Formats result using y1 and y2. (Required)
* @param date Date to use. Defaults to now(). (Optional)
* @return Returns a string.
* @author Toby Tremayne (toby@lyricist.com.au)
* @version 1, May 26, 2003
*/
function getCurrentFinYear(mask) {
var finYear = "";
var partOne = "";
var partTwo = "";
var date = now();
if(arrayLen(arguments) gte 2) date = arguments[2];
// if the current month falls in the first 6 months of the year...
if (month(date) lte 6) {
// first part is last year
partOne = year(dateAdd("yyyy", -1, date));
// second part is this year
partTwo = year(date);
} else {
// first part is this year
partOne = year(date);
// second part is next year
partTwo = year( dateAdd("yyyy", 1, date) );
}
// replace mask tokens for return
finYear = replaceNoCase(mask,"y1",partOne);
finYear = replaceNoCase(finYear,"y2",partTwo);
return finYear;
}
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