Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Problem with dates
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Problem with dates

 Post Reply Post Reply Page  12>
Author
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 Topic: Problem with dates
    Posted: 09 December 2003 at 1:03am

I have a problem with dates. The sql query below should select from an mySQL db all the records for which the DataExpirarii (expiration date) value is greater than present day. Instead, it selects all of them. What is wrong?

Set RS1 = MyConn.execute("Select NumeFirma, Pozitia, DataIntroducerii, ID From Oferte  where DataExpirarii > "& Date &"  Order By DataIntroducerii DESC Limit 10")
 

Cristian Banu
Soft 4 web
Back to Top
Paul Lush View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 24 September 2003
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote Paul Lush Quote  Post ReplyReply Direct Link To This Post Posted: 09 December 2003 at 4:05am

try putting the date in ' s

eg ' " & date & " '

then make sure you have a valid date with seperators, eg "1/1/2003" or "1-1-2003" instead of "1 1 2003"

Without the actual date value (for what we know , date could contain "wibble slobber"), its hard to tell.

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: 09 December 2003 at 4:14am
It doesn't work with '. It triggers the "Exception occur" error. Also, Response.writing both dates shows them correct 12/3/2003 and 12/09/2003. The field in the mySQL db is a Date field.
Cristian Banu
Soft 4 web
Back to Top
Paul Lush View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 24 September 2003
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote Paul Lush Quote  Post ReplyReply Direct Link To This Post Posted: 09 December 2003 at 4:27am

the ' was my mistake :(

have you tried " & cdate ( date ) & "

?

Im getting the same thing here in my msSQL server but as all of my work needs date selections, I always use BETWEEN

Back to Top
Paul Lush View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 24 September 2003
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote Paul Lush Quote  Post ReplyReply Direct Link To This Post Posted: 09 December 2003 at 4:32am

This works

"Select NumeFirma, Pozitia, DataIntroducerii, ID From Oferte  where DataExpirarii  > convert(datetime , '" & date & "', 121) Order By DataIntroducerii DESC Limit 10"

there are ' in there as well

Back to Top
Paul Lush View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 24 September 2003
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote Paul Lush Quote  Post ReplyReply Direct Link To This Post Posted: 09 December 2003 at 4:33am

Oh, make sure that you us US MM/DD/YYYY formatting.  That works in my msSQL, hard to tell in mySQL as I dont have it installed

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: 09 December 2003 at 4:34am

Nope, it doesn't work. The funny thing is that if I put there "2003-12-09" it works. I tryed to put it in a string with datePart, like in:

data =  DatePart("yyyy", Date) &"-"& DatePart("m", Date) &"-"&DatePart("d", Date) and then have the query with

"& data &"

but still does not work.

Cristian Banu
Soft 4 web
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: 09 December 2003 at 4:39am
The inner format for dates of MySQL is yyyy-mm-dd.
Cristian Banu
Soft 4 web
Back to Top
 Post Reply Post Reply Page  12>

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.