Link to home
Start Free TrialLog in
Avatar of sergio_2001
sergio_2001

asked on

Date Format

Hi All,

In my app I'm using one dbEdit to show and save one date.
I do: (on BeforePost event)
dbEditDate.Text := FormatDateTime('dd/mm/yyyy', date);
It looks fine on the screen. But when I save this field the date is changed to 'mm/dd/yyyy' (inverse mm/dd).
There are anything I can do or that's the way the nature works????
I'm using ACCESS+ODBC+BDE+D3

Regards
Paulo
ASKER CERTIFIED SOLUTION
Avatar of rwilson032697
rwilson032697

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rwilson032697
rwilson032697

Oops, I got shortdateformat wrong:

procedure test;

begin
  shortdateformat := 'd/m/yyyy';  // <-------- It should be like this...
  ShowMessage('Date = '+datetostr(now));
end;


Watch out - the datetostr routine is not Y2K compliant !!!
Avatar of sergio_2001

ASKER

Hi rwilson,

I suppose ShortDateFormat solve.
But does it saves in db in this format?
Where is the best place within the proj. to put ShortDateFormat?

Regards
Paulo
joanita: In what way is it not comliant? Note that D4 IS compliant.

sergio_2001: You always store the dates in the database in the same way (perhaps as a TDateTime). What we are doing here is presenting the date to the user in a particular way. When you store that date into the database it will be as a TDatetime again...

Cheers,

Raymond.
rw:
Y2K standards refered to are British Standards
     Institution (BSI) document DISC PD 2000-1, A Definition of Year 2000
and
     Conformity Requirements and SAA/SNZ MP77:1998 : A Definition of Year 2000
 conformity requirements (Revised November 1998) of Standards Australia.
Regret, I wasnt being specific. Prior D4 is not compliant.
I have tried the following statement in D3

edit1.Text := DateToStr(StrToDate('2000/01/01'));

the value of edit1.Text is '2000/01/01'.

Does this apply that DateToStr is Y2K compliant?
I have tried the following statement in D3

edit1.Text := DateToStr(StrToDate('2000/01/01'));

the value of edit1.Text is '2000/01/01'.

Does this apply that DateToStr is Y2K compliant?
Shortie: DateToStr and StrToDate are compliant. What joanita was probably referring to is how two digit centuries are handled. Delphi uses a century window (which you can set) to control how years spanning 2000 are handled.

Raymond.