I did it like this and was able to get it to work, now I am just curious as 
to whether this is the most efficient(or just efficient) way
to do it.

<!---Begin ProRated Calculation Code--->
<!---Variable Initialization--->
<cfset Month=#DatePart('m',GetDate.HireDate)#>
<hr>CFSwitch Expression=Month::#Month#<hr>
<!---IF Day is 1 determine Month then set Multiplier--->
<cfif GetDate.HireDate is not "" and DatePart('d',GetDate.HireDate) is 1>
<CFSwitch expression="#Month#">
<cfcase value="1">
<cfset Multiplier=12/12>
#Multiplier#
</cfcase>
<cfcase value="2">
<cfset Multiplier=11/12>
#Multiplier#
</cfcase><cfcase value="3">
<cfset Multiplier=10/12>
#Multiplier#
</cfcase><cfcase value="4">
<cfset Multiplier=9/12>
#Multiplier#
</cfcase><cfcase value="5">
<cfset Multiplier=8/12>
#Multiplier#
</cfcase><cfcase value="6">
<cfset Multiplier=7/12>
#Multiplier#
</cfcase><cfcase value="7">
<cfset Multiplier=6/12>
#Multiplier#
</cfcase><cfcase value="8">
<cfset Multiplier=5/12>
#Multiplier#
</cfcase><cfcase value="9">
<cfset Multiplier=4/12>
#Multiplier#
</cfcase><cfcase value="10">
<cfset Multiplier=3/12>
#Multiplier#
</cfcase><cfcase value="11">
<cfset Multiplier=2/12>
#Multiplier#
</cfcase><cfcase value="12">
<cfset Multiplier=1/12>
#Multiplier#
</cfcase>
</cfswitch>
<!---IF Day is 2 or Greater determine Month then set Multiplier--->
<cfelse>
<CFSwitch expression="#Month#">
<cfcase value="1">
<cfset Multiplier=11/12>
#Multiplier#
</cfcase>
<cfcase value="2">
<cfset Multiplier=10/12>
#Multiplier#
</cfcase><cfcase value="3">
<cfset Multiplier=9/12>
#Multiplier#
</cfcase><cfcase value="4">
<cfset Multiplier=8/12>
#Multiplier#
</cfcase><cfcase value="5">
<cfset Multiplier=7/12>
#Multiplier#
</cfcase><cfcase value="6">
<cfset Multiplier=6/12>
#Multiplier#
</cfcase><cfcase value="7">
<cfset Multiplier=5/12>
#Multiplier#
</cfcase><cfcase value="8">
<cfset Multiplier=4/12>
#Multiplier#
</cfcase><cfcase value="9">
<cfset Multiplier=3/12>
#Multiplier#
</cfcase><cfcase value="10">
<cfset Multiplier=2/12>
#Multiplier#
</cfcase><cfcase value="11">
<cfset Multiplier=1/12>
#Multiplier#
</cfcase>
</cfswitch>
</cfif>
</cfoutput>
<!---End ProRated Calculation Code--->


>From: Cameron Childress" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: CF-Talk <[EMAIL PROTECTED]>
>Subject: RE: CF Prorating Based Date Expression
>Date: Fri, 4 Jan 2002 11:41:48 -0500
>
>Do you only want to prorate by month?  If I understand your question, you
>can do it pretty easy down to the day.  Look at the DayofYear() function.
>Something like this should work:
>
>CFSCRIPT
>
>if(IsLeapYear(Year(HireDate))) {
>       daysInYear = 366;
>}else{
>       daysInYear = 365;
>}
>
>YearPartEmployed = (daysInYear-DayofYear(HireDate))/daysInYear;
>
>/CFSCRIPT
>
>-Cameron
>
>--------------------
>Cameron Childress
>elliptIQ Inc.
>p.770.460.1035.232
>f.770.460.0963
>--
>http://www.neighborware.com
>America's Leading Community Network Software
>
>
>
>
>
> > -----Original Message-----
> > From: David D <[EMAIL PROTECTED]> [mailto:David D
> > <[EMAIL PROTECTED]>]
> > Sent: Friday, January 04, 2002 10:33 AM
> > To: CF-Talk
> > Subject: CF Prorating Based Date Expression
> >
> >
> > Hello,
> >
> > I am looking to calculate based on the HireDate vs. the YearBegin Date.
> >
> > Ex: employee was hired 1/1/2002 which is YearBegin Date and shall
> > therefore
> > be calculated at 12/12 or 100%.
> >
> > Ex2: employee was hired on 2/1/2002 versus YearBegin of 1/1/2002 and
> > therefore calculations should be based on 11/12 or 91.6%
> >
> > Example 3 (where it gets hairy or at least hairier): is where
> > employee was
> > hired on 2/2/2002 and therefore should calculate at 10/12 since he 
>wasn't
> > there for the 1st.
> >
> > I was trying to use DateCompare() and then saw DateDiff() but they don's
> > seem to differentiate between another month based on the day not
> > being the
> > first, ie. DateDiff is saying that 2/1/2002 is 1 month past
> > 1/1/2002 and it
> > also says that 2/2/2002 is also 1 month past, instead of 2.
> >
> > Any ideas on to how I should proceed with this would be greatly
> > appreciated.
> >
> > Thanks,
> >
> > Dave
> >
> > _________________________________________________________________
> > Get your FREE download of MSN Explorer at
>http://explorer.msn.com/intl.asp.
>
>
______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to