Results 1 to 3 of 3
  1. #1
    andy101 is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Posts
    2

    Short date comparison

    Hi,



    I'm trying to find if a specific date appears within a table. The code I am using works if the date doesn't have a leading zero in it e.g. 12/11/2011

    strSQL = "SELECT Holidays.EmployeeID, Holidays.Dates, Holidays.Period FROM Holidays WHERE Holidays.Dates = #" & datebooked & "#;"

    But when I search for 01/02/2011 it seems the zeros are being removed in the query and therefore the date isn't found in the table when it actual is there!

    Any help would be much appreciated.

    Thanks,

    Andy.

  2. #2
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    Try this:
    strSQL = "SELECT Holidays.EmployeeID, Holidays.Dates, Holidays.Period FROM Holidays WHERE Holidays.Dates = #" & Format(datebooked, "m/d/yy") & "#;"

  3. #3
    andy101 is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Posts
    2

    Smile

    That works great, thank you. Why does it work like that when I store the dates in the format dd/mm/yyyy?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Comparison Feature Help
    By Kapelluschsa in forum Access
    Replies: 2
    Last Post: 10-25-2010, 06:43 AM
  2. Boolean Comparison Not Working
    By Rawb in forum Programming
    Replies: 4
    Last Post: 09-03-2010, 09:17 AM
  3. Comparison
    By VICTOR HUGO in forum Access
    Replies: 8
    Last Post: 02-10-2010, 04:32 PM
  4. CTRL +' Short Cut Key
    By desireemm1 in forum Access
    Replies: 2
    Last Post: 09-10-2009, 03:25 PM
  5. Time Comparison
    By Larry819 in forum Queries
    Replies: 1
    Last Post: 06-22-2009, 09:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums