Count by Day and Month but not by Year

Homer J

New member
Local time
Today, 02:45
Joined
Jun 28, 2004
Messages
6
I have a table with Inception Dates (dd/mm/yyyy) and the number of policies sold on that date. I want to create a query that counts how many policies that have been sold. I know thats easy, but I'm not interested in the year part of the date.

I just want to know how many were sold on that day/month irrespective of the year. I tried using Format but it then it wasnt in date order which I need.

Help!
Thanks
Homer J
 
SELECT count(*) as NoPolicies, str(Month(InceptionDate)) as Month, str(Day(InceptionDate)) as Day
From MyTable
Group By str(Month(InceptionDate)), str(Day(InceptionDate))
Order By str(Month(InceptionDate)), str(Day(InceptionDate))

Actually the order by in the case above is redundent since the group by should order it for you, but in case you want a different sort order I included it. This may need tweaking since it is just off the top of my head. But you know it would group say May 2003 entries with May 2004 entries since you are ignoring the year.
 

Users who are viewing this thread

Back
Top Bottom