Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    The sunny side of the Alps
    Posts
    230
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Retireving data from date/time field?

    Hi!

    I have an ASP page and try to read from an Access database. I want to retrieve all records where "Date_Job" field (it is date/time field) in not "1.1.1900". This is the query I use:

    sDate = CDate("1.1.1900")
    sSQL = "SELECT * from employee WHERE Not Date_Job = '" & sDate & "'"
    set rs = conn.execute(sSQL)

    But I get this error:

    Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
    [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.


    What am I doing wrong?

    Thanks,
    Bostjan

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Stillwater Ok
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this as your WHERE statement.

    WHERE Date_Job != '" & sDate & "'"

    Good luck.
    "Never offend people with style when you can offend them with substance."
    --Sam Brown

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I usually use the CONVERT DATETIME() SQL function with SQL Server, I haven't tried it with Access so I don't know if it works-

    Something like this that I just cooked up in Access should work for you (you can also make the date a variable, to expand on this idea):

    SELECT * FROM employee WHERE employee.Date_Job <> #1/1/1900#

    *Note: Dave said this already pretty much, I just thought that since the post above his contained an incorrect "not equals" sign for SQL I would try to clarify the situation a bit.

    Last edited by whammy; 07-10-2002 at 01:03 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

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