WeekStartDate(weekNum, weekYear[, ISOFormat])
Last updated March 19, 2002
Version: 1 | Requires: CF5 | 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:
<cfoutput>
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:
/**
* 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;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016