Re: date format



On Tue, 30 Jan 2007 21:33:05 +0100, Jean-Paul De Winter
<jp.dewinter@xxxxxxxxxx> wrote:

Hi,
I have a table with a field called "Datum"
Here the date of records are stored in format DD/MM/YYYY

Not really. The date is *STORED* as a Double Float number, a count of
days (and fractions of days, if you have a time portion) since
midnight, December 30, 1899. The Format assigned to a field only
controls how it is *displayed*, not what's stored.

In my code I wrote:

Dim Starten as Date
Dim SQL as string

then in the code itself I wrote:
sql = "SELECT Agenda.datum FROM agenda WHERE Agenda.datum=#" & starten "#;"

This returns
SELECT Agenda.datum FROM agenda WHERE Agenda.datum=#5/12/2005#;

No record is found because finally access seems to look for dates in the
format MM/DD/YYY

What to do?

Use the American mm/dd/yyyy format, or an unambiguous format such as
dd-mmm-yyyy or yyyy.mm.dd; for instance,

sql = SELECT Agenda.datum FROM agenda WHERE Agenda.datum=#" & _
Format(starten, "mm/dd/yyyy") & "#;"

John W. Vinson[MVP]
.



Relevant Pages

  • Re: Date Format
    ... An Access Date/Time value is *stored* as a Double Float number, ... The format just controls how it's displayed. ... be in either American mm/dd/yyyy format or an unambiguous format such ... To insert UK dates in a SQL statement, ...
    (microsoft.public.access.queries)
  • Re: Date Format without the "/"
    ... Set the field to a string. ... Then run the format function over the top ... This will format what ever is in fieldname into the format dd/mm/yyyy ...
    (microsoft.public.access.forms)
  • Re: Date format detection
    ... Specifies the locale for which the date string is to be formatted. ... date format for this locale. ... the system default-date format for the specified locale. ... be enclosed within single quotation marks in the date format picture. ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Date format detection
    ... > Specifies the locale for which the date string is to be formatted. ... > date format for this locale. ... > the system default-date format for the specified locale. ... > be enclosed within single quotation marks in the date format picture. ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Date confusion
    ... Read my reply elsewhere in this string. ... > integer portion of the value represents the date as the number of days ... >> If you are working with a numeric date and you want the format DDMMYYYY, ... Another reason for preferring to store a date as text would be personal preference. ...
    (microsoft.public.access.modulesdaovba)