** NB ** This thread was split away from a technical question (Help on trouble handling date.).
Dates in SQL don't use Regional Settings.
This is why we get this question (or similar) so many times here. It doesn't help that many 'solutions' given out by experts seem to ignore this. The main reason for this, of course, is that the SQL standard format (which, as I said, is independent of Region) is the same as the Regional format for the USA (IE. m/d/yyyy). This means that a large part of the world never sees the problems involved with writing dates into SQL (and filters also contain SQL instructions of course) just as they come. Access uses Regional Settings to display dates, so date literals need to be formatted explicitly to work reliably in SQL (Even outside of the USA dates are often interpreted correctly even though in the wrong format because the SQL engine recognises dates such as 22/11/2011 as really being 11/22/2011 because there are only twelve months in a year).
For more on this see Literal DateTimes and Their Delimiters (#).
PS. To format a date correctly you can always use the following :
It is not always necessary to include the hashes (#) in there though, as these can easily be appended as part of the rest of the SQL string.
Dates in SQL don't use Regional Settings.
This is why we get this question (or similar) so many times here. It doesn't help that many 'solutions' given out by experts seem to ignore this. The main reason for this, of course, is that the SQL standard format (which, as I said, is independent of Region) is the same as the Regional format for the USA (IE. m/d/yyyy). This means that a large part of the world never sees the problems involved with writing dates into SQL (and filters also contain SQL instructions of course) just as they come. Access uses Regional Settings to display dates, so date literals need to be formatted explicitly to work reliably in SQL (Even outside of the USA dates are often interpreted correctly even though in the wrong format because the SQL engine recognises dates such as 22/11/2011 as really being 11/22/2011 because there are only twelve months in a year).
For more on this see Literal DateTimes and Their Delimiters (#).
PS. To format a date correctly you can always use the following :
Code:
Format([DateVal], "\#m/d/yyyy\#")
Comment