Here one way to do it:

<!-- begin  -->
<pre>
Subject: How can I find the date of the monday of the week containing a
given date?

<cfoutput>

<!--- set the current date --->
<cfset today = DateFormat(now(), "mm-dd-yyyy")>

Current Date: #today#

<!--- figure out which day of the week the current date is --->
<cfset today_dow = DayOfWeek(today)>

Current Day of the Week: #today_dow#

<!--- figure out how many days there are back to the beginning of the week --->
<cfset days_to_week_begin = 7-today_dow>

Days to beginning of week: #days_to_week_begin#

<!--- now that we know how many days there are back to the beginning of the week, we 
can subtract that number from the current date to figure out the date of the beginning 
of the week --->

<cfset week_begin_date = today-days_to_week_begin>

Week begin date: #DateFormat(week_begin_date, "mm-dd-yyyy")#

</cfoutput>
</pre>
<!-- end -->

--------------------------------------------------------------
Mark Warrick
Phone: (714) 547-5386
Efax.com Fax: (801) 730-7289
Personal Email: [EMAIL PROTECTED]
Personal URL: http://www.warrick.net 
Business Email: [EMAIL PROTECTED]
Business URL: http://www.fusioneers.com
ICQ: 346566
--------------------------------------------------------------


> -----Original Message-----
> From: Brent Goldman [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 19, 2000 6:29 PM
> To: CF-Talk
> Subject: How can I find the date of the monday of the week containing a
> given date?
> 
> 
> Hello,
> 
> I am currently writing an online scheduling application with 
> ColdFusion.  At 
> one part of the program, I output the next four weeks in case the 
> user wants 
> to quickly jump ahead in time.  Rather than outputting weeks 
> starting from 
> the current day, such as from a Tuesday like today, I want the weeks 
> starting from a Monday.  So today's week would be Dec 18 (Mon) - Dec 24 
> (Sun), not Dec 19 (Tue) - Dec 25 (Mon).
> 
> I've looked at all of the ColdFusion date functions, but I can't 
> figure out 
> how to use them to retrieve the date of the Monday of the week 
> containing a 
> given date.  Does anyone know how to do this?  Someone please help.
> 
> Thanks,
> Brent
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to