CFLib.org – Common Function Library Project

dailyBusinessReportDateRange(dateIn)

Last updated April 4, 2007

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

 
Rated 1 time(s). Average Rating: 5.0

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:

view plain print about
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:

view plain print about
<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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
12 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
30 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson