Results 1 to 3 of 3

Thread: SQL syntax for date

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Location
    Birmingham
    Posts
    2

    SQL syntax for date

    hi....this website has got me going...i need help with the syntax of the following SQL in vb....cant seem to get the date into the SQL properly. Please help....thanks!!! Need to find age older than certain date!!

    the SQL syntax for Date ?

    Dim dSearch AS date

    dSearch = InputBox$("Enter date to show employees older than","QUERY")

    Data1.recordsource = "SELECT * FROM StaffDetails WHERE StaffDetails.[Date-of-Birth] <= " &dSearch

    I thought about not putting the speech marks after dSearch as it is a date and not string....any suggestions??? Many thanks

  2. #2
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    u need to use # before and after dates in SQL.

    ex.

    rs.Open "SELECT * FROM tblWhatever WHERE birthDate = #" & txtDate.text & "#"

  3. #3
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    You have to surround dates with the pound symbol

    VB Code:
    1. sSQL = " SELECT * FROM TABLE WHERE MY_DATE >= #15-JAN-2001#"

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