CFLib.org – Common Function Library Project

GetFirstDateinQuarter(quarter)

Last updated February 14, 2004

author

Brian Sweeney

Version: 1 | Requires: CF5 | Library: DateLib

Description:
Gets the first date in a given quarter.

Return Values:
Returns a date.

Example:

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

Parameters:

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

Full UDF Source:

/**
 * Gets the first date in a given quarter.
 * 
 * @param quarter      A number from 1 to 4. (Required)
 * @return Returns a date. 
 * @author Brian Sweeney (brianvsweeney@hotmail.com) 
 * @version 1, February 14, 2004 
 */
function GetFirstDateinQuarter(quarter){
    switch(quarter){
        case 1:
            return CreateDate(year(now()), 1, 1);
            break;
        case 2:
            return CreateDate(year(now()), 4, 1);
            break;
        case 3:
            return CreateDate(year(now()), 7, 1);
            break;
        case 4:
            return CreateDate(year(now()), 10, 1);
            break;
    }
}

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

Created by Raymond Camden / Design by Justin Johnson