Web Analytics Made Easy -
StatCounter Retireving data from date/time field? - CodingForum


No announcement yet.

Retireving data from date/time field?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Retireving data from date/time field?


    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?


  • #2
    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
      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; Jul 9, 2002, 08:03 PM.
      Former ASP Forum Moderator - I'm back!

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