How do you determine the beginning of a given week?
When building online calendars it's often useful to know the first day of the week for a given date. The following code returns the Sunday of the date provided. The code can easily be adjusted to return another day if required (see code comment).
request.startDate = now();
currentDayOfWeek = dayOfWeek(REQUEST.startDate);
offset = 1 - currentDayOfWeek;//change number to get a different weekday variables.startDate = createODBCDate(dateAdd("d", offset, request.startDate));
</cfscript>
This question was written by Oliver Merk.
It was last updated on June 13, 2006 at 1:28:08 PM EDT.
CFML Referenced
Categories
Comments
There are no comments for this entry.