Print Page | Close Window

Comparing Date Values

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=8793
Printed Date: 01 April 2026 at 4:23am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Comparing Date Values
Posted By: Misty
Subject: Comparing Date Values
Date Posted: 12 January 2004 at 12:06am

I need  some help. I have a form that has a hidden value (ex: 6-January-2004). I submit the value to the next web page that adds to the database. It is not comparing right. Remember that the hiddenDate is something like 6-January-2004. The eventdate field in the db is something like 1/6/2004 or Tuesday, January 6, 2004.

'Check to see if the database already has this date

If HiddenDate = rs("EventDate") Then

Can someone please tell me how to make the hiddenDate value compare to the db field correctly? I cannot seem to get it working.

 




Replies:
Posted By: zaboss
Date Posted: 12 January 2004 at 1:38am

In order to work you need to have dates in the same format. Otherwise it gets confused. You should use DatePart function to retrieve the date from the db in the same format that you have in the hidden value.

So, you'll have:

<% EventData =  DatePart("d", rs("EventDate")) &"-"& DatePart("m", rs("EventDate") &"-"&DatePart("yyyy", rs("eventDate")  %>

If HiddenDate=EventData then...



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: psycotik
Date Posted: 12 January 2004 at 1:49am

Another idea might be do use CDate() to force it into the same format.

If CDate(HiddenDate) = rs("EventDate") Then..

This is assuming the field is set to a date and not a string in the db.

note;Hiddendate must be a valid date or the cast will fail.



Posted By: ljamal
Date Posted: 12 January 2004 at 8:10am
Converting both into date format is what I suggest

If CDate(HiddenDate) = CDate(EventDate) then

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net