This topic is locked
[SOLVED]

 Comparing Dates

3/22/2004 5:14:23 AM
ASPRunnerPro General questions
author

Hi, this doesn't work because even though I have defined the field as a Date field in Access and ASP Runner 2.4 this keeps comparing string values. Does anyone know how to code this correctly?
Thanks
<%

if Request.Form("VisitDate")> Request.Form("SubmittedDate") then

%>

<tr bgcolor="#cccccc"><td bgcolor="#ccccff"><b>Enter new Visit Date - you cannot forward date a report</b></td>

</tr>

<% end if %>

Sergey Kornilov admin 3/23/2004

No matter how you define fields Request.Form always store string values. Here is what you can try:

<%

if CDate(Request.Form("VisitDate"))> CDate(Request.Form("SubmittedDate")) then

%>

<tr bgcolor="#cccccc"><td bgcolor="#ccccff"><b>Enter new Visit Date - you cannot forward date a report</b></td>

</tr>

<% end if %>

501045 3/23/2004

Admin,

FYI - It is still doing a string comparison so it doesn't work. I just defaulted submit date = Date() and visit date = Date()-1. Hopefully this will elevate many of the errors. I had also changed from calendar type 2 to 6. It is amazing to see how many ways users can screw up a Date! Thanks, and please post a solution if anyone ever finds a way to easily convert the string back into a date to do the comparison and I will let you know if I find a solution as well.
Thanks again,

Bandit

501046 3/23/2004

Admin,
I just got it to work. Since I was comparing to Submit Date, which is not on the form but in the database and stated in the asp functions as Date(), all I had to do is after coverting Visit Date to a date is compare that to Date().
<%

if CDate(Request.Form("VisitDate"))> Date() then

%>

<tr bgcolor="#cccccc"><td bgcolor="#ccccff"><b>Enter new Visit Date - you cannot forward date a report</b></td>

</tr>

<% end if %>
Thanks for the assistance <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=1466&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />