Dekodowanie daty

0

Witam,

W plikach dbf mam zapisane daty w postaci: 000124, 00115, 000111 itd.

Jak robię

var
data : string;
begin
data:=DateToStr(000124);
showmessage(data);

, to w odpowiedzi mam: 03-05-1900.

Może ktoś wie jak tego stringa odczytać jako prawidłową datę.

Z góry dzięki za pomoc,

janek

0

Pierw musisz określić w jaki sposób ten string przechowuje datę.

Z tego co zrozumiałem to..

000124 --> 24 styczeń 2000 r.
00115 --> 5 listopad 2000 r.
000111 --> 11 styczeń 2000 r.
Czy tak?

Wobec tego czytaj to:

onverts a string to a TDateTime value.

Unit
SysUtils

Category

date/time routines

function StrToDate(const S: string): TDateTime;

Description

Call StrToDate to parse a string that specifies a date. If S does not contain a valid date, StrToDate raises an EConvertError exception.

S must consist of two or three numbers, separated by the character defined by the DateSeparator global variable. The order for month, day, and year is determined by the ShortDateFormat global variable--possible combinations are m/d/y, d/m/y, and y/m/d.

If S contains only two numbers, it is interpreted as a date (m/d or d/m) in the current year.

Year values between 0 and 99 are converted using the TwoDigitYearCenturyWindow global variable. If TwoDigitYearCenturyWindow is 0, year values between 0 and 99 are assumed to be in the current century. If TwoDigitYearCenturyWindow is greater than 0, its value is subtracted from the current year to determine the “pivot”; years on or after the pivot are kept in the current century, while years prior to the pivot are moved to the next century. For example:

Current year
TwoDigitYearCenturyWindow
Pivot date =
mm/dd/03 date =
mm/dd/50 date =
mm/dd/68
1998 0 1900 1903 1950 1968
2002 0 2000 2003 2050 2068
1998 50 1948 2003 1950 1968
2000 50 1950 2003 1950 1968
2002 50 1952 2003 2050 1968
2020 50 1970 2003 2050 2068
2020 10 2010 2103 2050 2068
Note: The format of the date string varies when the values of date/time formatting variables are changed.

I przekształć to do odpowiedniej postaci...

1 użytkowników online, w tym zalogowanych: 0, gości: 1