Board index » delphi » MS Access Date Format

MS Access Date Format

Hi,

Anyone know what the MS Access date format is? I'm trying to insert a new
record with today's date (NOW()).

Shew

 

Re:MS Access Date Format


Thanks Brian,

Another question, so how would you update the Access date field with #
signs? Is it
INSERT INTO dah (id, datex)
VALUES (1,'#08/01/1998#')

Shew

Quote
Brian Bushay TeamB wrote in message

<3b6ec74c.16766...@forums.borland.com>...
Quote

>>Anyone know what the MS Access date format is? I'm trying to insert a new
>>record with today's date (NOW()).

>I beleive Access excpects date Values to be delimited with pound signss

>#08/01/1998#

>--
>Brian Bushay (TeamB)
>Bbus...@DataGuidance.com

Re:MS Access Date Format


Quote
>Anyone know what the MS Access date format is? I'm trying to insert a new
>record with today's date (NOW()).

I beleive Access excpects date Values to be delimited with pound signss

#08/01/1998#

--
Brian Bushay (TeamB)
Bbus...@DataGuidance.com

Re:MS Access Date Format


Putting quotes around it makes it a string. Don't put quotes when
using # for date values.

Woody

Quote
Shew Leong wrote in message <6q0o08$s...@forums.borland.com>...
>Thanks Brian,

>Another question, so how would you update the Access date field with
#
>signs? Is it
>INSERT INTO dah (id, datex)
>VALUES (1,'#08/01/1998#')

>Shew

>Brian Bushay TeamB wrote in message
><3b6ec74c.16766...@forums.borland.com>...

>>>Anyone know what the MS Access date format is? I'm trying to insert
a new
>>>record with today's date (NOW()).

>>I beleive Access excpects date Values to be delimited with pound
signss

>>#08/01/1998#

>>--
>>Brian Bushay (TeamB)
>>Bbus...@DataGuidance.com

Re:MS Access Date Format


Quote
>Another question, so how would you update the Access date field with #
>signs? Is it
>INSERT INTO dah (id, datex)
>VALUES (1,'#08/01/1998#')

No.  I do not belive  there would not be any quotes in the expresion around the
date.  

INSERT INTO dah (id, datex)
VALUES (1,#08/01/1998#)

However if you want to use SQL on an ACCESS database it is best to work the
queries out in Access first becuse there are some peculiarities.

--
Brian Bushay (TeamB)
Bbus...@DataGuidance.com

Re:MS Access Date Format


Quote
Brian Bushay TeamB wrote:
> However if you want to use SQL on an ACCESS database it is best to work the
> queries out in Access first becuse there are some peculiarities.

And remember that the correct format is #MM/DD/YYYY# (months first).
Here is something I coded to simplify generating SQL-statements for
MS-Access. You can pass any value (atleast the ones I have needed so
far) and it returns a string in correct format

function SQLStr(Value: Variant): string;
var
   Year, Month, Day: word;
begin
   Result := VarToStr(Value);
   case varType(Value) of
       varString: Result := '"' + Result + '"';
       varDate:
       begin
           DecodeDate(VarToDateTime(Value), Year, Month, Day);
           Result := '#' + IntToStr(Month) + '/' + IntToStr(Day)
                   + '/' + IntToStr(Year) + '#';
       end;
       varEmpty, varNull: Result := '';
   end;
end;

---
Henri Suuronen

Re:MS Access Date Format


If you're using a table approach the following works

    MyTable.FieldByname('my_date_field').AsDateTime := Now();

If a SQL insert I think the format is mm/dd/yy hh:mm:ss am

Also, I've found it helpful if unsure about format  to do an export to a
text file from Access and look at it's default output.
I hope that helps.

Quote
Brian Bushay TeamB wrote in message

<3b6ec74c.16766...@forums.borland.com>...
Quote

>>Anyone know what the MS Access date format is? I'm trying to insert a new
>>record with today's date (NOW()).

>I beleive Access excpects date Values to be delimited with pound signss

>#08/01/1998#

>--
>Brian Bushay (TeamB)
>Bbus...@DataGuidance.com

Other Threads