Leif:
How Access interprets a date entered at the parameter prompt when the query
is opened depends on the regional date settings in Windows Control panel on
the system:
1. If the date is entered in an internationally unambiguous format such as
the ISO standard of 2009-04-15 or a format such as 15 April 2009 then it will
be correctly interpreted whatever the regional settings.
2. If the parameter is entered in whatever format is set as the regional
short date format on the system it will be correctly interpreted whatever the
date.
3. If the regional short date setting is the US format 04/15/2009 or UK
format 15/04/2009 and the parameter is entered in that format it will be
correctly interpreted for dates after the 12th of each month whether the
parameter is entered as 04/15/2009 or 04/15/2009, but if the date is on or
before the 12th of the month then if entered in the wrong format it will be
'incorrectly' interpreted. On a system set to US short date format for
instance 07/04/2009 will be interpreted as 4 July 2009 although intended to
be 7 April 2009. The same will apply if the date is entered in US format on
a system set to UK short date format, so 07/04/2009 would be interpreted as 7
April 2009, not 4 July 2009.
If the query will be opened on a system of known date format, then you can
prompt the user to enter the date in that format, e.g. [Enter date in format
dd/mm/yyyy:] if the UK short date format is the system's regional short date
setting. If it is to be opened on systems of various possible regional date
formats, and you are not confidant of the users using the correct format for
the system when entering the parameter, then specifying an internationally
unambiguous format in the prompt would be advisable.
Another possible problem is that a parameter entered in short date format
such as 15/04/2009 could be mistakenly interpreted as an arithmetical
expression rather than a date, and give the wrong results. For this reason
date/time parameters should always be declared in a query. You can do this
in design view or by switching to SQL view and adding the parameter
declaration to the start of the query, e.g.
PARAMETERS [Enter date in format dd/mm/yyyy:] DATETIME;
SELECT *
FROM [MyTable]
WHERE [Nxt Contact] = [Enter date in format dd/mm/yyyy:];
Finally, in versions of Access since 1995 date literals, whether entered in
VBA or SQL (Jet), delimited by the # character must be in US format or an
internationally unambiguous format. I always use the ISO format
#2009-04-15#. Prior to 1995 date literals in VBA, but not in SQL, recognized
the system's regional date setting.
Ken Sheridan
Stafford, England
Leif Thorsen said:
I have a Date-field in a table named "Nxt contact" in the form "Short date" =
2009-04-15 for example.
When I make a query with that table and let the question ask for a
particular date in "Nxt contact" I will not beeing asked to write the wanted
value in the form "Short date". How can I write the question so I always know
in what form I shall write asked value in ???
Thank You in advance
Leif