CFLib.org – Common Function Library Project

GetLastDateinQuarter(quarter)

Last updated February 14, 2004

author

Brian Sweeney

Version: 1 | Requires: CF5 | Library: DateLib

Description:
Gets the last date in a given quarter.

Return Values:
Returna a date.

Example:

<cfloop index="x" from=1 to=4>
	<cfoutput>#getLastDateInQuarter(x)# = #quarter(getLastDateInQuarter(x))#<br></cfoutput>
</cfloop>

Parameters:

Name Description Required
quarter A number from 1 to 4. Yes

Full UDF Source:

/**
 * Gets the last date in a given quarter.
 * 
 * @param quarter 	 A number from 1 to 4. (Required)
 * @return Returna a date. 
 * @author Brian Sweeney (brianvsweeney@hotmail.com) 
 * @version 1, February 14, 2004 
 */
function GetLastDateinQuarter(quarter){
	switch(quarter){
		case 1:
			return CreateDate(year(now()), 3, DaysInMonth(CreateDate(year(now()),3,1)));
			break;
		case 2:
			return CreateDate(year(now()), 6, DaysInMonth(CreateDate(year(now()),6,1)));
			break;
		case 3:
			return CreateDate(year(now()), 9, DaysInMonth(CreateDate(year(now()),9,1)));
			break;
		case 4:
			return CreateDate(year(now()), 12, DaysInMonth(CreateDate(year(now()),12,1)));
			break;
	}
}
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