– Common Function Library Project


Last updated April 4, 2007


Dharmesh Goel

Version: 1 | Requires: CF5 | Library: DateLib

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.


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>


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

Full UDF Source:

 * 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 ( 
 * @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;
blog comments powered by Disqus


Latest Additions

Kevin Cotton added
May 5, 2016

Raymond Camden added
April 25, 2016

Chris Wigginton added
January 18, 2016

Gary Stanton added
November 19, 2015

Sebastiaan Naafs - van Dijk added
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson