Solved

Date Format

Posted on 1999-01-11
9
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

734 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