Ooppps...
  I missed a couple of things in the arguments setup. This should work.
  <cffunction access="public" name="GetNthOccOfDayInMonth" output="No"
returntype="any">
<!--- Args [ASR] --->
<cfargument name="NthOccurrence" required="Yes" type="string">
<cfargument name="TheDayOfWeek" required="Yes" type="string">
<cfargument name="TheMonth" required="Yes" type="string">
<cfargument name="TheYear" required="Yes" type="string">

<!--- Vars [ASR] --->
<cfset Var TheDayInMonth = 0>
<cfset var myReturnVar = "">
<!--- Action Code [ASR] --->
<cfscript>
if(Arguments.TheDayOfWeek lt DayOfWeek(CreateDate(Arguments.TheYear,
Arguments.TheMonth,1)))
{
TheDayInMonth= 1 + Arguments.NthOccurrence*7 + (Arguments.TheDayOfWeek -
DayOfWeek(CreateDate(Arguments.TheYear,Arguments.TheMonth,1))) MOD 7;
}
else
{
TheDayInMonth= 1 + (Arguments.NthOccurrence-1)*7 + (Arguments.TheDayOfWeek -
DayOfWeek(CreateDate(Arguments.TheYear,Arguments.TheMonth,1))) MOD 7;
}
//If the result is greater than days in month or less than 1, return -1
if(TheDayInMonth gt DaysInMonth(CreateDate(TheYear,TheMonth,1)) OR
TheDayInMonth lt 1)
{myReturnVar = 1;}
else
{myReturnVar = TheDayInMonth;}
</cfscript>
<!--- Return value [ASR] --->
<cfreturn myReturnVar/>
</cffunction>

 On 10/26/05, Alan Rother <[EMAIL PROTECTED]> wrote:
>
> This should work, but I didn't test it
>  <cffunction access="public" name="GetNthOccOfDayInMonth" output="No"
> returntype="any">
> <!--- Args [ASR] --->
> <cfargument name="NthOccurrence" required="" type="">
> <cfargument name="TheDayOfWeek" required="" type="">
> <cfargument name="TheMonth" required="" type="">
> <cfargument name="TheYear" required="" type="">
>
> <!--- Vars [ASR] --->
> <cfset Var TheDayInMonth = 0>
> <cfset var myReturnVar = "">
> <!--- Action Code [ASR] --->
> <cfscript>
> if(Arguments.TheDayOfWeek lt DayOfWeek(CreateDate( Arguments.TheYear,
> Arguments.TheMonth,1)))
> {
> TheDayInMonth= 1 + Arguments.NthOccurrence*7 + (Arguments.TheDayOfWeek -
> DayOfWeek(CreateDate(Arguments.TheYear,Arguments.TheMonth,1))) MOD 7;
> }
> else
> {
> TheDayInMonth= 1 + (Arguments.NthOccurrence-1)*7 + (Arguments.TheDayOfWeek- 
> DayOfWeek(CreateDate(
> Arguments.TheYear,Arguments.TheMonth,1))) MOD 7;
> }
> //If the result is greater than days in month or less than 1, return -1
> if(TheDayInMonth gt DaysInMonth(CreateDate(TheYear,TheMonth,1)) OR
> TheDayInMonth lt 1)
> {myReturnVar = 1;}
> else
> {myReturnVar = TheDayInMonth;}
> </cfscript>
> <!--- Return value [ASR] --->
> <cfreturn myReturnVar/>
> </cffunction>
>  Enjoy
>  =]
>
>  On 10/26/05, Ken <[EMAIL PROTECTED]> wrote:
> >
> > Hi. I am new to CFC. Can someone help me convert this function from
> > cfscript
> > to CFML?
> >
> > <cfscript>
> > /**
> > * Returns the day of the month(1-31) of an Nth Occurrence of a day
> > (1-sunday,2-monday etc.)in a given month.
> > *
> > * @param NthOccurrence A number representing the nth occurrence.1-5.
> > * @param TheDayOfWeek A number representing the day of the week
> > (1=Sunday,
> > 2=Monday, etc.).
> > * @param TheMonth A number representing the Month (1=January,
> > 2=February,
> > etc.).
> > * @param TheYear The year.
> > */
> > function
> > GetNthOccOfDayInMonth(NthOccurrence,TheDayOfWeek,TheMonth,TheYear)
> > {
> > Var TheDayInMonth=0;
> > if(TheDayOfWeek lt DayOfWeek(CreateDate(TheYear,TheMonth,1))){
> > TheDayInMonth= 1 + NthOccurrence*7 + (TheDayOfWeek -
> > DayOfWeek(CreateDate(TheYear,TheMonth,1))) MOD 7;
> > }
> > else{
> > TheDayInMonth= 1 + (NthOccurrence-1)*7 + (TheDayOfWeek -
> > DayOfWeek(CreateDate(TheYear,TheMonth,1))) MOD 7;
> > }
> > //If the result is greater than days in month or less than 1, return -1
> > if(TheDayInMonth gt DaysInMonth(CreateDate(TheYear,TheMonth,1)) OR
> > TheDayInMonth lt 1){
> > return -1;
> > }
> > else{
> > return TheDayInMonth;
> > }
> > }
> > </cfscript>
> >
> >
> > Thanks,
> >
> > - Ken
> >
> >
> > 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:222385
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