Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Comparing Date Values
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Comparing Date Values

 Post Reply Post Reply
Author
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Topic: Comparing Date Values
    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.

 

Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post 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
Soft 4 web
Back to Top
psycotik View Drop Down
Groupie
Groupie


Joined: 27 November 2003
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote psycotik Quote  Post ReplyReply Direct Link To This Post 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.



Edited by psycotik
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 12 January 2004 at 8:10am
Converting both into date format is what I suggest

If CDate(HiddenDate) = CDate(EventDate) then
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.