CFLib.org – Common Function Library Project

getCurrentGradYear(switchmonth)

Last updated March 30, 2006

author

Lisa D. Brown

Version: 1 | Requires: CF5 | Library: DateLib

Description:
Returns the current graduation year/end of school year (returns -1 on an error). Useful for determining which school year we are currently in as opposed to which fiscal year. Uses the now(), Month(), and Year() functions.

Return Values:
Returns a number.

Example:

<cfoutput>#getcurrentGradYear(9)#</cfoutput>

Parameters:

Name Description Required
switchmonth Numeric value for the first month of the school year. Yes

Full UDF Source:

<!---
 Gets the current graduation year/end of school year.
 
 @param switchmonth 	 Numeric value for the first month of the school year. (Required)
 @return Returns a number. 
 @author Lisa D. Brown (wertle@wertle.com) 
 @version 1, April 9, 2007 
--->
<cffunction name="getCurrentGradYear" returntype="numeric">
	<!---last month of a schoolyear--->
	<cfargument name="switchmonth" type="numeric" required="no" default="6">
	<cfset var currGradYear = -1>

	<!---if the current month is between January and the last month of the schoolyear, 
	set the current graduation year to the current year--->
	<cfif month(now()) gte 1 and month(now()) lte arguments.switchmonth>
		<cfset currGradYear = year(now())>
	<!---if the current month is between the first month of the schoolyear and December,
	 set the current graduation year to be next year--->
	<cfelseif month(now()) gt arguments.switchmonth and month(now()) lte 12>
		<cfset currGradYear = year(now()) + 1>
	</cfif>
	<cfreturn currGradYear>
</cffunction>
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