CFLib.org – Common Function Library Project

GetSeason([myDate])

Last updated May 13, 2003

author

William Steiner

Version: 1 | Requires: CF5 | Library: DateLib

Description:
Returns the Season for a given date. If no date is specified, defaults to the current date.

Return Values:
Returns a string.

Example:

<CFOUTPUT>
The current season is #GetSeason()#.
</CFOUTPUT>

Parameters:

Name Description Required
myDate The date. Defaults to now. No

Full UDF Source:

/**
 * Returns season for given date.
 * 
 * @param myDate      The date. Defaults to now. (Optional)
 * @return Returns a string. 
 * @author William Steiner (williams@hkusa.com) 
 * @version 1, May 13, 2003 
 */
function GetSeason() {
    var myDate = iif(arraylen(arguments) gt 0,"arguments[1]", "now()");
    var myYear = Year(myDate);
    //Winter
    var winterStart = '12-21-' & decrementValue(myYear);
    var winterEnd = '03-20-' & myYear;
    //Spring
    var springStart = '3-21-' & myYear;
    var springEnd = '06-20-' & myYear;
    //Summenr 
    var summerStart = '06-21-' & myYear;
    var summerEnd ='09-20-' & myYear;
    //Fall
    var fallStart = '09-21-' & myYear;
    var fallEnd = '12-20-' & myYear;
    
    // return the correct season
    if (myDate GTE winterStart AND myDate LTE winterEnd) {
        return "Winter";
    } else if (myDate GTE springStart AND myDate LTE springEnd) {
        return "Spring";
    } else if (myDate GTE summerStart AND myDate LTE summerEnd) {
        return "Summer";
    } else if (myDate GTE fallStart AND myDate LTE fallEnd) {
        return "Fall";
    } else {
        return "";
    }
}

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