Brett_A wrote on 3 Jan 2007 07:03:09 -0800:
Quote:
I have the following code:
>
If ad_expiration_date (date() + 90) then
ad_expiration_date = (date() + 90)
else
end if
>
What I want to happen is if the ad_expiration_date entered by the user
is beyond 90 days from today's date, the Expiration Date should be
today's date plus 90 days. If the entered date is less than 90 days
from today's date, leave it as entered.
>
The code isn't working correctly, all dates entered are getting
converted to today's date plus 90 days.
>
What's wrong?
|
Probably the date format - it may not be what you expect. For instance, if
ad_expiration_date is a string containing "7/12/2006", depending on the
date/time settings for the user account that your ASP code is running under
that date could be either 7th Dec 2006 or 12th Jul 2006. Also, if
ad_expiration_date is a string, it may be that the ASP code is converting
the (date() + 90) to a string prior to comparison - I can't remember the
data type coercion rules, so it's just a stab in the dark. To debug this,
add this bit of code just before the above code:
Response.Write ad_expiration_date & "<br>"
Response.Write CDate(ad_expiration_date) & "<br>"
Response.Write Date() + 90 & "<br>"
Hopefully from these 3 values you'll be able to spot why it's not working as
you expect it to.
Dan