WeekStartDate(weekNum, weekYear [, ISOFormat])
Last updated March 19, 2002
Version: 1 | Requires: ColdFusion 5 | Library: DateLib
Description:
Takes a week number and returns a date object of the first day of that week. This can be useful if you want to display an actual date that can be easily understood by a person as opposed to a week number. By default, Sunday is considered the first day of the week. If you pass the optional ISOFormat argument, you can set Monday as the first day of the week.
Return Values:
Returns a date object.
Example:
This data was aquired the week of #dateFormat(weekStartDate(12,2002),"mm/dd/yyyy")#
</cfoutput>
Parameters:
| Name | Description | Required |
|---|---|---|
| weekNum | The week number. | Yes |
| weekYear | The year. | Yes |
| ISOFormat | Use ISO for first day of week. Defaults to false. | No |
Full UDF Source:
<cfscript>
/**
* Takes a week number and returns a date object of the first day of that week.
* Added ISOFormat, RCamden, 3/19/2002
*
* @param weekNum The week number.
* @param weekYear The year.
* @param ISOFormat Use ISO for first day of week. Defaults to false.
* @return Returns a date object.
* @author David Murphy (dmurphy52@lycos.com)
* @version 1, March 19, 2002
*/
function weekStartDate(weekNum,weekYear) {
var weekDate = dateAdd("WW",weekNum-1,"1/1/" & weekYear);
var toDay1 = dayofweek(weekDate)-1;
var weekStartDate = dateAdd("d",-toDay1,weekDate);
if(arrayLen(arguments) gte 3 and arguments[3]) weekStartDate = dateAdd("d",1,weekStartDate);
return weekStartDate;
}
</cfscript>
Search CFLib.org
Latest Additions
Shawn Porter added
DeMoronize
3 hour(s) ago
Chris Carey added
readPropertiesFi...
1 day(s) ago
Randy Johnson added
lastDayofWeek
3 day(s) ago
Frank Marion added
sitemapPing
7 day(s) ago
Top Rated
QuickSort
Rated 5.0, 3 time(s)
indentXml
Rated 5.0, 3 time(s)
queryColumnsToSt...
Rated 5.0, 3 time(s)
generateSsccAsn
Rated 5.0, 3 time(s)