Current Date Anniversary Query

  • Thread starter Thread starter AndyH
  • Start date Start date
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
 
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()))
 
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
 
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
 
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
 

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

Back
Top