Re: dates as query criteria



The # delimiter is correct for literal dates within the SQL statement (and
in VBA also.)

When adding paramters to a query, do not add the # to the parameter name.

Internally, Access actually stores dates as real numbers, where the integer
part represents the date and the fraction part the time. You can see this
for yourself if you open the Immediate window (Ctrl+G) and enter:
? CDbl(Now())

Using text (e.g. may) inside the # is not correct.

For details on how Access interprets date entries, see:
International Date Formats in Access
at:
http://allenbrowne.com/ser-36.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Doug F." <DougF@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C2394829-7F81-440A-BC5B-9C1AF49DADFB@xxxxxxxxxxxxxxxx
On the query grid for a date field I can hardcode #5/7/2006# but find that
using #may/7/2006# is more reliable as it's specific and unambiguous, ie
is
it May 7 or July 5 that I want. Does the local machine setting do the
determination when using the #5/7/2006# format? Is my #may/7/2006#
solution
commonly used?

Also, I believe that I must use the #...# to indicate a date, true? When
I
use the between [date1] and [date2] construct as a user prompt must I use
##
somehow?
Thanks.
--
Doug F.


.



Relevant Pages

  • Re: Basics of VBA and SQL
    ... Dim strQry As String ... The DoCmd.OpenQuery method requires the NAME of a saved query, ... Using a SQL statement in VBA would require the DoCmd.RunSQL strQry ...
    (microsoft.public.access.modulesdaovba)
  • Re: Basics of VBA and SQL
    ... Dim strQry As String ... The DoCmd.OpenQuery method requires the NAME of a saved query, ... Using a SQL statement in VBA would require the DoCmd.RunSQL strQry ...
    (microsoft.public.access.modulesdaovba)
  • Re: Pass Through Query Parameters
    ... I don't have much of a VBA ... >With a pass through query, ... the form control into ... >> call the form fields in the SQL statement, ...
    (microsoft.public.access.queries)
  • Re: Combine update queries into one query
    ... a query object, or execute the SQL statement from VBA. ... you could call a user-defined VBA ... > I have a schedule database that uses 9 update queries ...
    (microsoft.public.access.queries)
  • Re: Error using " in .open with ADODB.Recordset
    ... recordset but I'm getting hung up on the SQL statement. ... query that has a string as a condition. ... Dim mrk As String ...
    (microsoft.public.data.ado)