Results 1 to 14 of 14

Thread: Date < Now ?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212

    Exclamation Date < Now ?

    What's wrong with this code ?
    When used in PWS, it works ok, but on IIS, it displays all the date greater than now.

    Code:
    rs.Source = "SELECT * FROM Information WHERE [Return date] < '" & Now & "'"
    I also tried this, w/o success :

    Code:
    rs.Source = "SELECT * FROM Information WHERE [Return date] < #" & Now & "#"
    Regards,

    El-Nino

  2. #2
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Check the clock on your server. The SQL should be totally independant of whether you're running PWS or IIS.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212
    Well PWS is installed on a french Win98 System : The dateformat is : 2001/07/05 while IIS run on an english 2000 server where dateformat is 5/7/2001.

    I tried reformatting the strings manually, but stills no go.
    Any idea what might me causing this issue ?
    I tried that and no go, to my surprise :

    Code:
    rs.Source = "SELECT * FROM Information WHERE [Return date] < #" & "2001/07/05" & "#"
    Edited for spelling mistakes
    Regards,

    El-Nino

  4. #4
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    You have to get the dates in the same format before you try to compare them. I've run into this sort of issue before..
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  5. #5
    Lively Member harsoni's Avatar
    Join Date
    Oct 2000
    Posts
    118
    Hi,
    When you say now it returns you date and the time. So take the date part alone by formatting and then pass that to the sql query. Hope that will work for you.

    Sonia

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212
    That's why I posted this code earlier :
    It doesn't work neither, although dates are stored identically in db !

    Code:
    rs.Source = "SELECT * FROM Information WHERE [Return date] < #" & "2001/07/05" & "#"
    Regards,

    El-Nino

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212
    I just noticed that the db stored the date as a string. I cannot change this due to the large amount of data in it and I don't want to be held responsible for possible loss of data. Could this have an impact on the comparison ? If so, how can I accomplish this ?
    Regards,

    El-Nino

  8. #8
    Lively Member
    Join Date
    May 2001
    Posts
    127
    Actually you are better off using DateDiff

    I have never seen a < or > or = for that matter work with dates

    Try This

    Code:
    IntegerVariable = DateDiff("d", CDate(FirstDate), Date())
    if the FirstDate is < Then it returns a Negative Number if it is greater it returns possitive, if it is the same day then it is =

  9. #9
    Lively Member
    Join Date
    May 2001
    Posts
    127
    Ack Never Mind me, you were after a SQL Statement

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212
    Aynone ?
    Regards,

    El-Nino

  11. #11
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    What Db format is it. I know SQL Server has CAST and CONVERT functions you could use to go from string to date -- one of them is part of ANSI SQL, the other MS T-SQL, can't remember which is which.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212
    It is an Access DB.
    Regards,

    El-Nino

  13. #13
    New Member
    Join Date
    Jan 2001
    Posts
    9
    just check the dateformat of the [return date] and see that both the format is same if not same just convert to the saem format or u can use datediff(d,getdate(),[return date])


    pls. reply if this works out

    kumarg
    [email protected]
    Software Engineer,
    Post Box No 169
    Postal Code 113
    Muscat
    Oman

  14. #14
    New Member
    Join Date
    Jul 2001
    Location
    Nashua, NH
    Posts
    6

    Date < now

    Now is a keyword and not a variable so you do not need '" & now & "'
    try just now
    hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width