Query by Date and Month

jerryg72

New Member
Joined
Dec 30, 2005
Messages
40
I have a db with Name of Person and their DoB and Wedding Anniversary by Date and Month only (dd-mmm), but when I do the query, it does not give me result for the inputed dates. It was working perfectly earlier, but I don't know what happened now. Please help. Thank you
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Is your Anniversary date field Text or Date data type?
Note that if it is Date, even though you have formatted it NOT to show the year, the year really is part of the field, so that needs to be considered.

Can you also post the SQL code of your query so we can see your criteria for this field?
 
Upvote 0
Thank you Joe4 for the quick response. YES! my anniversary and B'day field is Date type. But, I tried to change to "short text" but as you said it was showing the year 2016 in all the date fields.

The SQL code is as follows:

SELECT RelateT.Names, RelateT.DoB, RelateT.Phone, RelateT.Email
FROM RelateT
WHERE (((RelateT.DoB) Between [Enter the start date:] And [Enter the end date:]));
 
Upvote 0
Do you Start and End Dates ever cross years?
Are you always entering in current year dates?
 
Upvote 0
I didn't get your 1st point Joe4. When I enter date I only give the day and month.
And the birth years are different for each person.
 
Upvote 0
If you only enter the day and month in a date field Access will automatically add the current year.
 
Upvote 0
I have a db with Name of Person and their DoB and Wedding Anniversary by Date and Month only (dd-mmm)

my anniversary and B'day field is Date type.

It doesn't entirely make sense that you have anniversaries stored by date and month (dd-mmm) in a database using Date fields. Date fields will always include a year.

If so, you will have to make sure your query looks for the month and day parts of the anniversary dates, and not just match directly on the field value.

something like:
....where Month(myDate) = Month(AnniversaryDate) AND Day(myDate) = Day(AnniversaryDate)

and of course you have to take leap year into account for anniversaries that only come once every four years or so.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,710
Messages
6,161,445
Members
451,706
Latest member
SMB1982

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top