CFLib.org – Common Function Library Project

dailyBusinessReportDateRange(dateIn)

Last updated April 4, 2007
Download UDF

author

Dharmesh Goel                                     Dharmesh Goel

Version: 1 | Requires: ColdFusion 5 | Library: DateLib

Description:
Returns a time range for a particular date from midnight to 11:59:59 the same day. If it is a Monday, the start date range begins from Saturday 12:00 AM till end of day Monday. This is helpful for reports run on business days. Usually a process runs 7 days a week early in the morning but a report is run manually only from Monday to Friday. So every day of the week except for Monday gets data for that day. On Monday, current days data as well as weekend's data are lumped together.

Return Values:
Returns a string.

Example:

Any day except Monday : <cfoutput>#dailyBusinessReportDateRange('10/24/2006')#</cfoutput><br>
A Monday : <cfoutput>#dailyBusinessReportDateRange('10/23/2006')#</cfoutput><br>
Current Date : <cfoutput>#dailyBusinessReportDateRange(Now())#</cfoutput><br>

Parameters:

Name Description Required
dateIn Date value to use for range. Yes

Full UDF Source:

<cfscript>
/**
* Returns a time range for a particular date from midnight to 11:59:59 the same day except for Monday.
*
* @param dateIn      Date value to use for range. (Required)
* @return Returns a string.
* @author Dharmesh Goel (drgoel@yahoo.com)
* @version 1, April 4, 2007
*/

function dailyBusinessReportDateRange(dateIn) {
    var dateRange = "";
    var dateOut1 = "";
    var dateOut2 = "";
    
    dateIn = dateFormat(dateIn, 'MM/DD/YYYY');
    
    if(dayOfWeek(dateIn) EQ 2) {
        dateOut1 = dateAdd("d",-2,dateIn);
        dateOut2 = dateadd("s",-1,dateAdd("d",1,dateIn));
    } else {
        dateOut1 = dateAdd("d",0,dateIn);
        dateOut2 = dateadd("s",-1,dateAdd("d",1,dateIn));
    }
    dateRange = dateout1 & "," & dateOut2;

    return dateRange;
}
</cfscript>

Search CFLib.org


Latest Additions

Raymond Compton Raymond Compton added
structBlend
20 day(s) ago

Duncan Duncan added
IsZIPUK
20 day(s) ago

Todd Sharp Todd Sharp added
getTagContentAll
26 day(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Created by Raymond Camden / Design by Justin Johnson