sql query give incorrect results (date/time) issue

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi to all.
I am pretty new to this stuff , so forgive me if I am asking the
obvious.
I am trying to extract some data from an Access database and am having
some trouble.
The SQL query that I am using (in VB.net) searches for products
depending on selected operator and a timespan.
The query works fine is my PC's system date setting is mm/dd/yyyy.
If I change it to dd/mm/yyyy the query does not return any info.

Here is the relevant code. I get the "timespan" from 2 sets of
comboboxes , that set the start and end date. ie: 21 June 2005 to 30
June 2005. The operator is also from a combobox.
-------------------------------------------------------------------


stday = Val(comStartday.SelectedItem)
stmnth = Val(comstartMnth.SelectedIndex + 1)
styr = Val(comstartyr.SelectedItem)

finday = Val(comfinday.SelectedItem)
finmnth = Val(comfinmnth.SelectedIndex + 1)
finyr = Val(comfinyr.SelectedItem)

Dim findate As DateTime = New Date(finyr, finmnth, finday, 23,
59, 59)
Dim stdate As DateTime = New Date(styr, stmnth, stday)


Dim getproducts As New OleDb.OleDbCommand("select
distinct(prod) from loginfo where oper = '" & comoperator.SelectedItem
& "' and DT >= # " & stdate & "# and DT <= #" & findate & "# ",
startup_form.mycon)


Hope you can work out what is going on there!!

The results of the query are used to populate a listbox(code not shown)

How can I make the code work on any system with any regional settings.

Thanks
Robin

.



Relevant Pages

  • Re: Data Query Question - Built in W2K - Works Fine - Run on XP -
    ... There are not settings in Excel, I was referring to the operating system ... regional settings on both, although as you are using US dates, most things ... > executing the query yields only blank adddate records. ... the adddate field shows as mm/dd/yyyy format. ...
    (microsoft.public.excel.crashesgpfs)
  • Re: Under what conditions will a query work on one machine but not ano
    ... First thing to check would be the version of JET. ... On the Version tab, you see the major version, and the minor version ... Under Regional Settings, what differences are there? ... You can actually minimize the differences in regional settings if you declare your non-text parameters, and typecast your calculated query fields as described here: ...
    (microsoft.public.access.queries)
  • Re: Under what conditions will a query work on one machine but not
    ... Under Regional Settings, what differences are there? ... and typecast your calculated query fields ... post the SQL statement that yields different results. ... Allen Browne - Microsoft MVP. ...
    (microsoft.public.access.queries)
  • Re: Under what conditions will a query work on one machine but not
    ... Allen Browne - Microsoft MVP. ... Tips for Access users - http://allenbrowne.com/tips.html ... Under Regional Settings, what differences are there? ... and typecast your calculated query fields ...
    (microsoft.public.access.queries)
  • Re: Date Format complications
    ... The date display in the Query grid is confusing since it varies according to ... I use the SQL View to check date literals. ... SQL) MUST be in the US format mm/dd/yyyy and delimited by hashes ... *regardless* of your Regional Settings. ...
    (microsoft.public.access.queries)