A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Figure months from a anchor date



 
 
Thread Tools Display Modes
  #1  
Old February 19th, 2007, 07:34 PM posted to microsoft.public.access.queries
buckpeace
external usenet poster
 
Posts: 18
Default Figure months from a anchor date

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
  #2  
Old February 19th, 2007, 08:40 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Figure months from a anchor date

On Mon, 19 Feb 2007 11:34:00 -0800, buckpeace
wrote:

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]
  #3  
Old February 19th, 2007, 08:48 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Figure months from a anchor date

buckpeace wrote:

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)

--
Marsh
MVP [MS Access]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.