Z
Z
Zulkund2016-09-30 13:54:24
Delphi
Zulkund, 2016-09-30 13:54:24

Date conversion in Delphi 7?

Good afternoon! Help to solve the problem in Delphi! It is necessary to create the form with two Edit'mi. In the first one, you need to enter a date in any format (DD.MM.YY ; DD/MM/YY ; YYYY/MM/DD) you need to read this date and convert it to a date format (dd.MM.YYYY), thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kalapanga, 2016-09-30
@kalapanga

There is a variant via variant :)
Edit2.Text := DateToStr(VarToDateTime(Edit1.Text));
But in the general case, it does not convert exactly to the dd.MM.YYYY format, but according to your settings.

M
Mercury13, 2016-09-30
@Mercury13

I don’t remember Delphi 7 for a long time, but there was a version of StrToDate there too ...
Multiple formats - multiple TFormatSettings.
Further. The release of accidents is an inefficient thing, and therefore it is desirable that accidents really fall out in accidents. I don't know if there is in Delphi 7, but there should be such a function.
It signals failure by returning false.
And finally. Be careful, in the USA the date format is slashed, but MM/DD/YY. There is also an ISO date format, YYYY-MM-DD.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question