Re: date format inconsistent

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Many thanks John

You're spot on I had changed the code but not the query! Apologies for the
confusion.

Now produces:

SELECT DISTINCT Jobdata.Labname FROM Jobs LEFT JOIN Jobdata ON
Jobs.JobNumber = Jobdata.JobNumber WHERE (((Jobdata.Labname) Is Not Null)
AND ((Jobdata.Labweek) = #06/Jan/2008#) AND ((Jobs.Complete) = False));

date has been handled as per previous reply.

Thanks.

"John W. Vinson" <jvinson@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:g6n943pe9opvl4tmf9sbg43tb9mqkmr97e@xxxxxxxxxx
On Fri, 11 May 2007 17:48:41 +0100, "Starry" <nospam> wrote:

Despite reading all I can I cannot seem to work around this.

My query is flipping ambiguous dates to US format. If it is passed a date
of
say 23/08/2009 it works fine but given the following or anything where the
date and month can be changed it does! How can I prevent this? All related
fields etc are set as UK.

Date literals MUST be in either US mm/dd/yyyy format, or an unambiguous
format
such as yyyy-mm-dd or yyyy-mmm-dd. The query engine does *not* check or
respect the system date/time settings... period.

A date which makes no sense in mm/dd/yyyy format (23/08/2009) will be
flipped
if that makes it reasonable; but 12/08/2009 is December 8, not 12th
August.
There is no setting or formatting to change this behavior.

You'll need to coerce literal dates into an acceptable format: e.g.

strsql = "SELECT Jobdata.Labname"
strsql = strsql & " FROM Jobs LEFT JOIN Jobdata ON Jobs.JobNumber =
Jobdata.JobNumber"
strsql = strsql & " GROUP BY Jobdata.Labname, Jobdata.Labweek,
Jobs.Complete"
strsql = strsql & " WHERE (((Jobdata.Labname) Is Not Null) AND
((Jobdata.Labweek) = #" & Format(dteWeekend, "mm\/dd\/yyyy") & "#) AND
((Jobs.Complete) = False));"

Note that I changed HAVING to WHERE - the WHERE clause filters records
*before* calculating the totals, HAVING calculates it after.

On looking again - *why* are you using a Group By at all? You're not
counting,
or summing, or averaging anything! If you just want the labname, use a
Select
query (with no totals) and set its Unique Values property to Yes.

John W. Vinson [MVP]


.



Relevant Pages

  • Re: Very Weird Date Format Problem
    ... Many, many, many thanks John. ... the date fields set format to d All but L1 display the day. ... The query uses a stored field which is the first of the month. ...
    (microsoft.public.access.reports)
  • Re: Export results from a Query
    ... "John Nurick" wrote: ... > Dim strSQL 'As String ... I run this query and direct the ouput to a folder. ...
    (microsoft.public.access.externaldata)
  • Re: Modify Query on the fly
    ... Dim StrSQL as String, strWhere As String ... John Spencer ... I have this created a query for my "combo box" to list out related ...
    (microsoft.public.access.gettingstarted)
  • Re: Type Conversion Failure
    ... John, can you typecast the field in your query? ... I have an Append Query that worked fine in Access97 but now fails to ... It will not let me format the ...
    (comp.databases.ms-access)
  • Re: Why doesnt this update work?
    ... "Brian" wrote in message ... In my ACCESS query via DoCmd.OpenQuery my> field Forms!!BookingDate> passes format dd/mm/yyyy but in my DoCmd.RunSQL it passes> format mm/dd/yyyy! ... >>> that it is a problem using the DoCmd.RunSQL strSQL>>> construct. ...
    (microsoft.public.access.queries)