Hi All -
I've been doing a little experimenting (A2010) to see how Access handles dates in queries and code, and my conclusion is that if Microsoft has been trying to confuse the world, they have succeeded beyond their wildest dreams.
Here's what I did. I have a little database for golf scores, with a PlayDate field, type Date. Three of the records have a value of Oct 5, 2010.
Now, common wisdom (not mine, apparently) says when you use dates in query criteria and use the '#' delimiter, the date has to be in mm-dd-yy format, i.e. month first. So, Oct. 5, 2010 is 10-5-2010.
I wote a simple little query to show two fields, and put this in the date critera: 10-5-2010.
Access automatically changed it to #10/05/2010#, which is fine.
I run the query and - no records! ???
Now I look at the SQL for the query :
SELECT [Golf Scores].PlayDate, [Golf Scores].CourseCode
FROM [Golf Scores]
WHERE ((([Golf Scores].PlayDate)=#5/10/2010#));
Access has reversed the month/day in the date!!! Small wonder it didn't work.
I don't know what others out there think, but I call that a MAJOR bug. I am in Canada, and our system date format is set to dd-mm-yyy, and I wonder if Access is being just a little too clever for its own good (and ours) and is somehow using that setting in the query.
Just to add to the confusion, in the immediate window (VBA more or less), a DCount:
?dcount("playdate","[Golf Scores]","playdate=#10-5-2010#")
DOES require the mm-dd-yy format - the above gives 3 as expected.
Can anyone shed some light on this - is it a bug, or some obscure "undocumented feature"?
Thanks All!
John