Figure months from a anchor date

B

buckpeace

Lets say a child was born on 5-15-2004. (dob = Field 1)
There is an immunization SERVICE date (Field 2) of 5-18-2005

I need to write a query that will show me ONLY the children that had a
SERVICE DATE (above) within 12 months. Any help will be appreciated
Buck
 
J

John W. Vinson

Lets say a child was born on 5-15-2004. (dob = Field 1)
There is an immunization SERVICE date (Field 2) of 5-18-2005

I need to write a query that will show me ONLY the children that had a
SERVICE DATE (above) within 12 months. Any help will be appreciated
Buck

SELECT <whatever>
FROM <your table name>
WHERE DateDiff("m", [DOB], [SERVICE DATE]) <= 12


John W. Vinson [MVP]
 
M

Marshall Barton

buckpeace said:
Lets say a child was born on 5-15-2004. (dob = Field 1)
There is an immunization SERVICE date (Field 2) of 5-18-2005

I need to write a query that will show me ONLY the children that had a
SERVICE DATE (above) within 12 months. Any help will be appreciated


SELECT *
FROM table
WHERE servicedate <= DateAdd("yyyy", 1, dob)

or
WHERE servicedate <= DateAdd("m", 12, dob)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top