Hi,

I am trying to implement a script that will do one function between 9am and 2pm and 
another between 2pm and 9am.

My code is as follows.  Can anyone, perhaps, tell me what I am doing wrong here?




    <!-- we'll be using the current time quite a bit, so execute Now() once, and store 
it --->

<cfset dtnow = Now()>

    <!--- we'll need these values twice, so just calculate and store them once --->

<cfset ynow = DatePart("yyyy",dtnow)>
<cfset mnow = DatePart("m",dtnow)>
<cfset dnow = DatePart("d",dtnow)>

    <!--- create date/time variables --->

<cfset time1 = CreateDateTime(ynow,mnow,dnow,9,0,0)>  <!--- 9am --->
<cfset time2 = CreateDateTime(ynow,mnow,dnow,14,0,0)> <!--- 2pm --->

<!--- do our stuff --->
<cfif (DateCompare(dtnow,time1) EQ -1) AND (DateCompare(dtnow,time2) EQ 1)>
    <!--- stuff to do if the current time is between 9am and 2pm --->
<cfelse>
    <!--- stuff to do if the current time is between 2pm and 9am the next day --->
</cfif> 



Thank you,
Michael J. Sammut
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to