Alex wrote:


>Sorry for a confusion. Try that.

>ShortDateFormat := 'dd/mm/yy';
>StrToDate ('29/02/00');

>I just went futher in my testing and checked  StrToDate ('29/02/2000')
>without setting proper ShortDateFormat := 'dd/mm/yyyy'. Sorry again. This
>works. The above one does not.

'29/02/00' fails regardless of ShortDateFormat setting in D1. The '00' is
interpreted as this century 1900.

In D4 you could "initialize the SysUtils global variable
TwoDigitYearCenturyWindow" as advised on Delphi Y2k page to get '29/02/00'
to be valid as '29/02/2000'. I don't have D4 so can't check this.

The only safe way is explicit 4-digit years.

Tony Goodrich suggested using EncodeDate - only fine if you use 4-digit
years. Otherwise '99' becomes 99 AD - with shortdate format 'dd/mm/yy'
eg.7/7/99 you can't distinguish 99AD from 1999AD.
Year '00' won't work at all with EncodeDate (which may be a good thing!!).
If you do use 4-digit dates then strtodate, datetostr are fine.

Incidentally, the Delphi help in D1 & D3 both use the rather bizarre example
of
 MyDate := EncodeDate(83,12,31); which would be 31 December 89 AD!?
Perhaps even more bizarre is this:
"If the specified values are not within range, an EConvertError exception is
raised. The resulting value is one plus the number of days between
12/30/1899 and the given date."

Regards,
Mike

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to