CFLib.org – Common Function Library Project

lastDayofWeek([date])

Last updated August 30, 2010

author

Randy Johnson

Version: 1 | Requires: CF5 | Library: DateLib

Description:
This function will return the next Saturday after the date you pass in.

Return Values:
Returns a date.

Example:

<cfoutput>
#lastDayOfWeek()#<br/>
#lastDayOfWeek(now())#<br/>
#lastDayOfWeek(dateAdd("ww", 1, now()))#
</cfoutput>

Parameters:

Name Description Required
date Date to base 'next Saturday' on. Defaults to now(). No

Full UDF Source:

/**
 * Returns last day of the week, assumes Saturday is the last day.
 * Modded by RCamden to support default date
 * 
 * @param date 	 Date to base 'next Saturday' on. Defaults to now(). (Optional)
 * @return Returns a date. 
 * @author Randy Johnson (randy@cfconcepts.com) 
 * @version 1, August 30, 2010 
 */
function lastDayOfWeek() {
     var NumberOfDays="";
     var LastDayOfWeek = "";
     if(arrayLen(arguments) is 0) arguments.date = now();
     else arguments.date = arguments[1];
     date = trim(arguments.date);
	
     NumberOfDays = 7 - dayOfWeek(date);

     LastDayOfWeek = dateAdd("d", NumberOfDays, date);
    
     return LastDayOfWeek;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson