Results 1 to 2 of 2

Thread: Date Data Type & SQL

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Oporto, Portugal
    Posts
    134

    Post

    I tried to make an SQL statement that seached a DB for a single Date but I recived allways an error message for invalid data type. This means I tried this:
    Set rst = dbs.OpenRecordset("SELECT * FROM DBaes WHERE date =" & Var_Today)

    Where: "DBase" was my database
    "date" the field on the database with Date/Time data type
    "Var_Today" a variable with today date for comparison (I tried it as Variant, Date and String data type) all of them gave me error.

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    Try this:

    "Select * from MyTable where TheDateField = #" & MyStringOrDateVariable & "#"

    HTH

    Tom

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