Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date question

Status
Not open for further replies.

tsp1lrk

IS-IT--Management
Joined
May 30, 2001
Messages
103
Location
US
Hi,

I have a form that someone fills out to request a new eval. There is a submit date on it, the day the user puts the request in.

The eval expires in 90 days. I want to have the form compare the date the form was submitted and if it's past 90 days, excluding weekends of course. I want a message to say: your eval has expired, please resubmit your request.

Not sure where to start, newbie here!
Thanks,
Lisa
 
What you're wanting to do requires a little code. you want to exclude weekends which makes things harder.

If you choose to let the weekends stay in there, just do something like this.
Code:
<CFIF DateDiff('d', startDate, Now()) GE 90)>
   Your whatever has expired
<CFELSE>
   Your whatever will expire in #DateDiff('d', startDate, Now())# days.
</CFIF>
In order to do the weekend thing, you'd have to start a loop beginning with the start date. Increment through each day between the start date and the end date. For each date check if the day of the week is a 1 or a 7. If not, increment some kind of counter.

I suppose it would look something like this, but I haven't tested it. Also, there could be a better way.
Code:
<CFSET counter = 0>
<CFLOOP FROM=&quot;0&quot; TO=&quot;#DateDiff('d', startDate, Now())#&quot; INDEX=&quot;i&quot;>
   <CFIF Not((DayOfWeek(DateAdd('d', i, startDate)) IS 1) OR (DayOfWeek(DateAdd('d', i, startDate)) IS 7))>
      <CFSET counter = counter + 1>
   </CFIF>
</CFLOOP>

<CFIF counter GE 90>
   Your trial is over.
<CFELSE>
   You have #Evaluate(90 - counter)# left
</CFIF>
See how that works out for you.
Kevin
slanek@ssd.fsi.com

&quot;Life is what happens to you while you're busy making other plans.&quot;
- John Lennon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top