Try this Brent:

the code below will give you the date for Monday based on the date you enter

<cfset date = "12/18/2000">

<CFSET diff = 7 - dayofweek(date)>

<CFIF diff is 1>
        <CFSET diff = -4><!-- Today is Fri -->
<cfelseif diff is 2>
        <CFSET diff = -3><!-- Today is Thu -->
<cfelseif diff is 3>
        <CFSET diff = -2><!-- Today is Wed -->
<cfelseif diff is 4>
        <CFSET diff = -1><!-- Today is Tue -->
<cfelseif diff is 5>
        <cfset diff = 0><!-- Today is Mon -->
<cfelseif diff is 6>
        <cfset diff = +1><!-- Today is Sun -->
<cfelse>
        <cfset diff = +2><!-- Today is Sat -->
</CFIF>
<CFSET monday = dateadd("d", diff, date)>

<CFOUTPUT>
<!--- Sunday = 1 and Saturday = 7 --->
Mondays date is: #DateFormat(monday, "mmm dd, yyyy")#<BR>
</cfoutput>


Larry Juncker
Senior Cold Fusion Developer
Heartland Communications Group, Inc.


-----Original Message-----
From: Brent Goldman [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 19, 2000 8: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