Board index » delphi » Strtodate unction doesn't work with '29/02/00' date.......

Strtodate unction doesn't work with '29/02/00' date.......

        When I use the strtodate function with '29/02/00' date I got the following
message:
        "Project <Project Name> raised exception class EConvertError with
message "29/02/00" is not a valid date".
        I got the Modify2000 function below in the Inprise Site, but it doesn't
work with the date "29/02/00".

Ex:
var date:tdatetime
        date:=Modify2000(strtodate("29/02/00"));

function Modify2000(const Value : TDateTime): TDateTime;
var
     Year, Month, Day : Word;
begin
     Result := Value;
     DecodeDate(Result, Year, Month, Day);
     if Year < 1950 then
     Result:= EncodeDate(Year+100, Month, Day);

        Please, someone have a solution for it?

                                        Marco Roberto

 

Re:Strtodate unction doesn't work with '29/02/00' date.......


Marco,
  you are trying to set the date to 29/02/00?  Check your Regional Settings
in the Control Panel.  For this to work, your setting must be in the form
"dd/MM/yy".  My guess is it is set to "MM/dd/yy", where the month must come
first.  I think you can also set the ShortDateFormat and LongDataFormat in
your code if you don't want to change your Regional Settings.
-Howard Moon

Re:Strtodate unction doesn't work with '29/02/00' date.......


Marco Roberto Gon?alves Junior <mar...@patrimonio.com.br> wrote in article
<01be01ca$133dee80$7301a...@internetcom.internetcom>...

Quote
>    When I use the strtodate function with '29/02/00' date I got the
following
> message:
>    "Project <Project Name> raised exception class EConvertError with
> message "29/02/00" is not a valid date".
>    I got the Modify2000 function below in the Inprise Site, but it doesn't
> work with the date "29/02/00".

Since the century is left out 29/02/00 is assumed to be 29/02/1900. The
year 1900 wasn't a leap year, so there wasn't a February 29.

This is a special case that you'll have to check for separately.

        -- Kirk

Re:Strtodate unction doesn't work with '29/02/00' date.......


29/02/00 = 29/02/2000 is NOT a valid date.
2000 year is NOT a leap year !!!
there is a correction every 400 years, making that the year has only 365
days.

This is the hidden bug of Year 2000 ! Everybody speaks about 01/01/2000, but
few people think of 29/02/2000 !

Denis

Re:Strtodate unction doesn't work with '29/02/00' date.......


Denis,

Actually if the year is a century and divisible by 400 then it is a leap
year otherwise it is not.
Furthermore all date calculations prior to now would be wrong if Borland had
this reversed.

Check out Feb 29th for other century values 1600, 1700, 1800, 1900, 2100 ...

Garry Kernan

Quote
Denis Jeanroy wrote in message <7154av$g6...@aristote.pratique.fr>...
>29/02/00 = 29/02/2000 is NOT a valid date.
>2000 year is NOT a leap year !!!
>there is a correction every 400 years, making that the year has only 365
>days.

>This is the hidden bug of Year 2000 ! Everybody speaks about 01/01/2000,
but
>few people think of 29/02/2000 !

>Denis

Other Threads