You may assume that because I wasted some time on this that I don't have a life...well...no comment.

<cfset testdate = createdate(2004,03,28)><!--- typically will be now(). used createdate to test scenarios. --->
<cfset todayis = dayofweek(testdate)>
<cfset mondays = iif(todayis GT 2 and todayis LT 5,de("#evaluate(0-(todayis-(todayis-2)))#"),iif(todayis EQ 1,de("1"),iif(todayis EQ 7,de("2"),iif(todayis EQ 2,de("0"),de("-4")))) )>
<cfset fridays = iif(todayis GT 2 and todayis LT 5,de("#evaluate((6-todayis))#"),iif(todayis EQ 1,de("5"),iif(todayis EQ 7,de("6"),iif(todayis EQ 2,de("4"),de("0")))) )>
<cfset monday = dateformat(dateadd("d",mondays,testdate),"mm/dd/yy")>
<cfset friday = dateformat(dateadd("d",fridays,testdate),"mm/dd/yy")>
<cfoutput>today: #dateformat(testdate,"mm/dd/yy")# #todayis# monday:#monday# friday: #friday#</cfoutput>


<!--- breakin down the iifs...and we know how painful THAT can be...
mondays=iif(todayis GT 2 and todayis LT 5,de("#evaluate(0-(todayis-(todayis-2)))#"),x )
x=iif(todayis EQ 1,de("1"),y)
y=iif(todayis EQ 7,de("2"),z)
z=iif(todayis EQ 2,de("0"),zz)
zz=de("-4")


fridays=iif(todayis GT 2 and todayis LT 5,de("#evaluate((6-todayis))#"),x )
x=iif(todayis EQ 1,de("5"),y)
y=iif(todayis EQ 7,de("6"),z)
z=iif(todayis EQ 2,de("4"),zz)
zz=de("0") --->


From: [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [KCFusion] Day of the week formula
Date: Fri, 5 Mar 2004 17:40:36 -0600 (CST)


Here are some pages for finding the day of the week (ooops, Gregorian not Julian calendar)


Nice walkthrough: http://www.koshko.com/calendar/day-of-week.shtml

11 page real writeup: http://home.t-online.de/home/berndt.schwerdtfeger/cal/cal.pdf

Simple writeup: http://mathforum.org/dr.math/faq/faq.calendar.html

Search for 'day of the week' on cflib.org and you will find a few, make sure you use the right calendar (julian/gregorian):
http://www.cflib.org/udf.cfm?ID=155


http://www.cflib.org/udf.cfm?ID=234


Oh sure...after I spend 10 minutes looking....CF can do this already!!!


DayOfWeek(date) ,DayOfWeek
Description
Returns the ordinal for the day of the week. The day is given as an integer in the range 1 (Sunday) to 7 (Saturday).
When passing a date/time value as a string, enclose it in quotes. Otherwise, it is interpreted as a number representation of a date/time object.



Note


You can pass the CreateDate function or Now function as the date parameter of DayOfWeek: #DayOfYear(CreateDate(2001, 3, 3))#

,<cfset yourDate = CreateDate(FORM.year, FORM.month, FORM.day)>






========================================================= Kansas City ColdFusion User Group's website & listserv is hosted through the generous support of Clickdoug.com To send email to the list, email [EMAIL PROTECTED] To (un)subscribe, email [EMAIL PROTECTED] with your request. For hosting solutions http://www.clickdoug.com Featuring Win2003 Enterprise, RedHat Linux, CFMX 6.1. ======================================================

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar � get it now! http://clk.atdmt.com/AVE/go/onm00200415ave/direct/01/



=========================================================
Kansas City ColdFusion User Group's website & listserv is hosted through the generous support of Clickdoug.com
To send email to the list, email [EMAIL PROTECTED]
To (un)subscribe, email [EMAIL PROTECTED] with your request.
For hosting solutions http://www.clickdoug.com
Featuring Win2003 Enterprise, RedHat Linux, CFMX 6.1. ======================================================

Reply via email to