I needed a random date generator and I have found three different cffunction 
which teoretically should do exactly what I want. Unfortunately when I insert 
any of them in my utils.cfc I get the error that the method was not found in 
that component. The other methods included there work fine.

Please advise. Thank you very much.

One of the cffunction is the following:

<cffunction name="RandDateRange" access="public" returntype="date" 
output="false" hint="Returns a random date between the two passed in dates. If 
either of the two dates has a time value, the resultant time will also be 
randomized.">
<cfargument name="DateFrom" type="date" required="true" hint="The min date of 
the date range."/>
<cfargument name="DateTo" type="date" required="true" hint="The max date of the 
date range."/>
<cfargument name="IncludeRandomTime" type="boolean" required="false" 
default="false" hint="Will include the time in the date randomization even if 
neither passed-in dates have a time." />
<cfset var LOCAL = StructNew() />

<cfif ((ARGUMENTS.DateFrom NEQ Fix( ARGUMENTS.DateFrom )) OR (ARGUMENTS.DateTo 
NEQ Fix( ARGUMENTS.DateTo )) OR ARGUMENTS.IncludeRandomTime)>
   <cfset LOCAL.DiffSeconds = DateDiff("s",ARGUMENTS.DateFrom,ARGUMENTS.DateTo) 
/>
   <cfset LOCAL.Date = (ARGUMENTS.DateFrom + CreateTimeSpan(0,0,0,RandRange( 
0,LOCAL.DiffSeconds))) />
   <cfreturn DateFormat( LOCAL.Date ) & " " & TimeFormat( LOCAL.Date )/>
<cfelse>
   <cfreturn DateFormat( RandRange( ARGUMENTS.DateFrom, ARGUMENTS.DateTo)) />
</cfif>
</cffunction> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:3283
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to