Question

  • Creator
    Topic
  • #2197779

    SQL in MS ACCESS : Date handling

    Locked

    by grinder182533 ·

    My table (tblStaff) has a date of birth field (DOB) defined as a ‘General Date’.
    I need to write a Query that counts those rows where the staff are under 25 years old, at run time. I am new to SQL, so can anybody advise on the syntax please ?
    Many Thanks

All Answers

  • Author
    Replies
    • #2838778

      Clarifications

      by grinder182533 ·

      In reply to SQL in MS ACCESS : Date handling

      Clarifications

    • #3021086

      SQL in MS ACCESS : Date handling

      by grinder182533 ·

      In reply to SQL in MS ACCESS : Date handling

      I have solved this by using this coding :
      DateAdd(“yyyy”, 16, DOB) <= Date() & DateAdd("yyyy", 16, DOB) > Date()

    • #3021085

      Try this

      by tony hopkinson ·

      In reply to SQL in MS ACCESS : Date handling

      Select Count(*) From Staff Where DateAdd(year,25,DOB) < GetDate() Few other variations But DateAdd, DateSubtract ansd DatePart are along with GetDate() are usually in there somewhere.

      • #3020907

        SQL in MS ACCESS : Date handling

        by grinder182533 ·

        In reply to Try this

        Thanks Tony
        I have learned a lot more about dates these last few days !

Viewing 2 reply threads