Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Date Format

Posted on 1999-01-11
9
Medium Priority
?
257 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 300 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Loops Section Overview

886 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