GetNextDayOfWeek() returns the next specified DOW (1-7).
GetNetxNDayOfWeek() uses the first fucntion to return a query with the
next N occurances.
Test code below.
(I am on a slow connection, and just saw other responses come in, oh
well <g>).
<!--- Get the next occurrence of a DOW --->
<CFFUNCTION NAME="GetNextDayOfWeek">
<!--- DOW to get (1-7)--->
<CFARGUMENT NAME="dow" REQUIRED="yes" TYPE="numeric">
<!--- Start date, defaults to today --->
<CFARGUMENT NAME="startdate" REQUIRED="no" DEFAULT="#Now()#">
<!--- Get today DOW --->
<CFSET VAR today=DayOfWeek(startdate)>
<!--- Get next occurrence of specified DOW --->
<CFSET VAR nextday=dow-today>
<CFIF nextday LTE 0>
<CFSET nextday=nextday+7>
</CFIF>
<!--- And return it --->
<CFRETURN DateAdd("d", nextday, startdate)>
</CFFUNCTION>
<!--- Get next N occurrences of DOW (returns a query) --->
<CFFUNCTION NAME="GetNextNDayOfWeek" RETURNTYPE="query">
<!--- DOW to get (1-7)--->
<CFARGUMENT NAME="dow" REQUIRED="yes" TYPE="numeric">
<!--- Number of occurrences --->
<CFARGUMENT NAME="weeks" REQUIRED="yes" TYPE="numeric">
<!--- Start date, defaults to today --->
<CFARGUMENT NAME="startdate" REQUIRED="no" DEFAULT="#Now()#">
<!--- Create result query --->
<CFSET VAR result=QueryNew("date")>
<!--- Set start date --->
<CFSET VAR tmpdate=startdate>
<!--- Loop through occurrences --->
<CFLOOP INDEX="i" FROM="1" TO="#weeks#">
<!--- Get next occurrence --->
<CFSET tmpdate=GetNextDayOfWeek(dow, tmpdate)>
<!--- And add it to the query --->
<CFSET QueryAddRow(result)>
<CFSET QuerySetCell(result, "date", tmpdate)>
</CFLOOP>
<!--- Return the query --->
<CFRETURN result>
</CFFUNCTION>
<!--- Get next Saturday --->
<CFSET x=GetNextDayOfWeek(7)>
<CFDUMP VAR="#x#">
<!--- Test, get next 10 Mondays --->
<CFSET x=GetNextNDayOfWeek(2, 10)>
<CFDUMP VAR="#x#">
-----Original Message-----
From: Brad Roberts [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 13, 2002 2:24 PM
To: CF-Talk
Subject: Next 4 Saturdays
I need to display the next 4 Saturday's dates in a select box. Anyone
have any ideas for a "neat" solution?
-Brad
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists