Current Date Anniversary Query

A

AndyH

Hi
I have built a very simple small db that is basically a way of recording
events in history.
What I have is the following fields: category, date, heading and details

I am tring to do is run a query that will extract all the entries that fall
on today's date ie all the 3/11.
ie pull 3/11/2004 3/11/1999 3/11/2001 etc and leave the rest. The idea is to
extract all the current day anniversary events
I am a bit stuck what criteria to write in the query design. Tried the
expression builder no joy..

any advice would be greatly appreciated..
thanks in advance
andy
 
V

Van T. Dinh

You can use the criterion like:

..... WHERE Format([DateField], "mmdd") = Format(Date(), "mmdd")

or alternatively:

.... WHERE (Month([DateField]) = Month(Date()))
AND (Day([DateField]) =Day(Date()))
 
A

AndyH

Spot On
Many many thanks
andy
Van T. Dinh said:
You can use the criterion like:

.... WHERE Format([DateField], "mmdd") = Format(Date(), "mmdd")

or alternatively:

... WHERE (Month([DateField]) = Month(Date()))
AND (Day([DateField]) =Day(Date()))

--
HTH
Van T. Dinh
MVP (Access)



AndyH said:
Hi
I have built a very simple small db that is basically a way of recording
events in history.
What I have is the following fields: category, date, heading and details

I am tring to do is run a query that will extract all the entries that
fall on today's date ie all the 3/11.
ie pull 3/11/2004 3/11/1999 3/11/2001 etc and leave the rest. The idea is
to extract all the current day anniversary events
I am a bit stuck what criteria to write in the query design. Tried the
expression builder no joy..

any advice would be greatly appreciated..
thanks in advance
andy
 
S

Sprinks

Andy,

Use two calls to the DatePart function to match the month and day to today's
date.

SELECT YourTable.*
FROM YourTable
WHERE ((DatePart("m",[YourDateField])=DatePart("m",Date()) And
DatePart("d",[YourDateField])=DatePart("d",Date())));

Sprinks
 
J

James A. Fortune

AndyH said:
Hi
I have built a very simple small db that is basically a way of recording
events in history.
What I have is the following fields: category, date, heading and details

I am tring to do is run a query that will extract all the entries that fall
on today's date ie all the 3/11.
ie pull 3/11/2004 3/11/1999 3/11/2001 etc and leave the rest. The idea is to
extract all the current day anniversary events
I am a bit stuck what criteria to write in the query design. Tried the
expression builder no joy..

any advice would be greatly appreciated..
thanks in advance
andy

Events that happened on today's date:

SELECT EventName, EventDate FROM MyTable WHERE Month(EventDate) =
Month(Date()) AND Day(EventDate) = Day(Date());

or

SELECT EventName, EventDate FROM MyTable WHERE Format(EventDate,
'\.mmdd') = Format(Date(), '\.mmdd');

James A. Fortune
 
Top