How to use Date in criteria

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Cyd44
    New Member
    • Oct 2011
    • 101

    How to use Date in criteria

    I want to filtre a form to show only records <= current date and have the following SQL for the form

    Code:
    SELECT tblRoomsBooking.BookLocation, tblRoomsBooking.BookStartDate, tblRoomsBooking.BookTime, tblRoomsBooking.BookEndTime, tblRoomsBooking.BookName, tblRoomsBooking.Faculty, tblRoomsBooking.myID
    FROM tblRoomsBooking
    WHERE (((tblRoomsBooking.BookStartDate)<=Date()))
    ORDER BY tblRoomsBooking.BookLocation, tblRoomsBooking.BookStartDate;
    I have no complie error but the form does not appear to filtre the records according to my criteria?
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    What type of field is tblRoomsBooking .BookStartDate?

    Your code will fail unless the field type is DateTime.

    Comment

    • Cyd44
      New Member
      • Oct 2011
      • 101

      #3
      The field is set to Date/Time as a short date

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32661

        #4
        In that case I see no reason why any valid data would fail to behave as you'd expect.

        Can you explain what you see more clearly? Perhaps with data examples showing records that behave one way when you'd expect them to behave differently.

        Comment

        • Cyd44
          New Member
          • Oct 2011
          • 101

          #5
          The SQL is contained within the Form as Control source and under the BookStartDate field I have added criteria as <= Date()

          The Records were showing dates less that Date() and I am a total DUMMY for not realising it was working as intended. I wanted records in advance of today and should have had >= Date() not the way I had set it.

          Sorry for wisting your time, it was working as coded, I simply had not realised that.

          Comment

          Working...