CFLib.org – Common Function Library Project

getFirstDateThisQuarter()

Last updated August 11, 2005

author

Scott Glassbrook

Version: 1 | Requires: CF5 | Library: DateLib

Description:
This function returns a datetime string of the first date of the current quarter, using the Now() function.

Return Values:
Returns a date.

Example:

<cfoutput>#getFirstDateThisQuarter()#</cfoutput>

Parameters:

No arguments.

Full UDF Source:

/**
 * Returns a date object with the first date of the current quarter.
 * 
 * @return Returns a date. 
 * @author Scott Glassbrook (cflib@vox.phydiux.com) 
 * @version 1, August 11, 2005 
 */
function getFirstDateThisQuarter() {
	if(now() gte createDateTime(DatePart("yyyy", now()), 01, 01, 00, 00, 00) and now() lte createDateTime(DatePart("yyyy", now()), 03, 31, 23, 59, 59)) return createDate(datePart("yyyy", now()), 01, 01);
	else if (now() gte createDateTime(DatePart("yyyy", now()), 04, 01, 00, 00, 00) and now() lte createDateTime(DatePart("yyyy", now()), 06, 30, 23, 59, 59)) return createDate(datePart("yyyy", now()), 04, 01);
	else if (now() gte createDateTime(DatePart("yyyy", now()), 07, 01, 00, 00, 00) and now() lte createDateTime(DatePart("yyyy", now()), 09, 30, 23, 59, 59)) return createDate(datePart("yyyy", now()), 07, 01);
	else return createDate(datePart("yyyy", now()), 10, 01);
}
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