Hi All,
I’m having some problems filtering for a date with DCount. My regional settings are set to European date format (dd/mm/yyyy). In my final code I'm using a variable for the date, but to simplify things I'm just putting an actual date in the examples below.
If I look for the date number, it works:
The following also works, though the date is converted to the wrong format (US settings: mm/dd/yyyy). This means 01/06/2016 would be changed to 06/01/2016 and the record wouldn't be found.
As per suggestions in other threads, I’ve tried the following. But none of these work:
Can someone tell me what I’m doing wrong? Thanks for your help.
I’m having some problems filtering for a date with DCount. My regional settings are set to European date format (dd/mm/yyyy). In my final code I'm using a variable for the date, but to simplify things I'm just putting an actual date in the examples below.
If I look for the date number, it works:
Code:
DCount("*", "tbl_Holidays", "HolidayDate = 42729")
The following also works, though the date is converted to the wrong format (US settings: mm/dd/yyyy). This means 01/06/2016 would be changed to 06/01/2016 and the record wouldn't be found.
Code:
DCount("*", "tbl_Holidays", "HolidayDate = #25/12/2016#")
As per suggestions in other threads, I’ve tried the following. But none of these work:
Code:
DCount("*", "tbl_Holidays", "HolidayDate = #" & Format(25/12/2016, "dd/mm/yyyy") & "#")
DCount("*", "tbl_Holidays", "HolidayDate = " & Format(25/12/2016, "\#dd/mm/yyyy\#"))
DCount("*", "tbl_Holidays", "HolidayDate = " & CDbl(25/12/2016))
Can someone tell me what I’m doing wrong? Thanks for your help.