CFLib.org – Common Function Library Project

lastDayofWeek([date])

Last updated August 30, 2010

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

 
Rated 1 time(s). Average Rating: 5.0

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

Return Values:
Returns a date.

Example:

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

view plain print about
<cfscript>
/**
 * 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;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 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
29 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