I'm writing a script to insert groups of weekend dates in a db.  I've
managed to do it but I'm curious if I've written the most efficient way.
The dates will be entered by a form and I needed to compensate for the user
entering a start date that wasn't a weekend date, otherwise the first
conditional loop would fail.  Check my code below.  I've set the recurdate
and number of weekends manually for examples sake.  I adjust at the
beginning and end to ensure the next date set in the loop will be a weekend.
For some reason it just seems sloppy.

Thanks,
emmet


<cfoutput>

<CFSET RecurDate = #CreateDate(2005, 4, 19)#>

<cfloop index="RecurNum" FROM="1" TO="5">

<cfset adjust = evaluate(DayOfWeek(RECURDATE) - 7)>
<cfif adjust lt 0>
<cfset adjust = evaluate(-adjust)>
</cfif>
<CFSET RecurDate = #DateAdd('d', adjust, RecurDate)#>

<cfloop condition="DayOfWeek(RECURDATE) eq 1 OR DayOfWeek(RECURDATE) EQ 7">
                        #recurdate#<br>
                        <CFSET RecurDate = #DateAdd('d', 1, RecurDate)#>
                        </cfloop>
                        <cfset adjust = evaluate(DayOfWeek(RECURDATE) - 7)>
                        <cfif adjust lt 0>
                        <cfset adjust = evaluate(-adjust)>
                        </cfif>
                        
                        <CFSET RecurDate = #DateAdd('d', adjust,
RecurDate)#>
                        <br><br>
                        
                        
</cfloop>
</cfoutput>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203515
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to