Solved

Date Format

Posted on 1999-01-11
9
251 Views
Last Modified: 2010-04-06
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
0
Comment
Question by:sergio_2001
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 100 total points
ID: 1355950
You have a couple of options:

1. Use datetostr and strtodate (they use the ShortDateFormat whichh is initialised to  your locale settings. This is nice as it works in the users locale properly.

2. Set ShortDateFormat to 'dd/mm/yyyy'

Cheers,

Raymond.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1355951
Oops, I got shortdateformat wrong:

procedure test;

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


0
 

Expert Comment

by:joanita
ID: 1355952
Watch out - the datetostr routine is not Y2K compliant !!!
0
 

Author Comment

by:sergio_2001
ID: 1355953
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
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 12

Expert Comment

by:rwilson032697
ID: 1355954
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.
0
 

Expert Comment

by:joanita
ID: 1355955
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.
0
 

Expert Comment

by:shortie
ID: 1355956
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?
0
 

Expert Comment

by:shortie
ID: 1355957
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?
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1355958
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.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now