Date in WHERE statement

Results 1 to 2 of 2

Thread: Date in WHERE statement

  1. #1
    Join Date
    Dec 1969

    Default Date in WHERE statement

    In a ms Access database I have a date data type field that stores dates mm/dd/yy/ I need to write a SQL statement that gets the current date and the corisponding record from the database.<BR><BR>I have tryied<BR>sql_find = "SELECT * FROM jokes WHERE addate=02/20/2002"<BR>sql_find = "SELECT * FROM jokes WHERE addate=&#039;02/20/2002&#039;" <BR>sql_find = "SELECT * FROM jokes WHERE addate=" & date<BR>sql_find = "SELECT * FROM jokes WHERE addate=&#039;" & date & "&#039;"<BR>sql_find = "SELECT * FROM jokes WHERE addate=" & Cdate(date)<BR><BR>Nothing above works I either get a data type error ( in cases where I enclose it in quotes) Or I get EOF BOF errors.<BR><BR>To make sure the record was there I tested<BR>sql_find = "SELECT * FROM jokes WHERE id=5<BR>The date returned was 2/20/02<BR>the date retured when I response.write date was 2/20/02<BR>exactly the same, so where am I going wrong here?

  2. #2
    Join Date
    Dec 1969

    Default RE: Date in WHERE statement

    sql_find = "SELECT * FROM jokes WHERE addate=#" & date & "#"

Posting Permissions

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