Solved

Date Format

Posted on 1999-01-11
9
255 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
Independent Software Vendors: 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 8 hours left to enroll

623 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