Board index » delphi » SetRange() returns empty set if system date >=2000 year (additional info)

SetRange() returns empty set if system date >=2000 year (additional info)

Hi,
Lately I had to come back to databases and I found something strange in my
aplication;
Procedure SetRange() when system date >= 2000 year always returns empty data
set. If system date <=1999 year it works correctly.
???

Here are some details that may be helpful to resolve my strange??  problem.
I use
System: Windows 98;
Format of date:yy-mm-dd;
yy as year (two digits) is interpreted between 1930 and 2029;

Delphi Client/Server Suite 4.0;
I work with Paradox7 tables; Field that makes problems is Date type;

To input date I use TMaskEdit (EditMask:!00/00/00;1;_);
I noticed, function StrToDate() also don't give back correct value if system
date>=2000 year;
I"ve made very simple program to examine it:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Mask;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    MaskEdit1: TMaskEdit;
    Button1: TButton;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);

  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
   x: TDateTime;
begin
     x:=StrToDate(MaskEdit1.Text);
     Label1.Caption:=FloatToStr(x);
     Label2.Caption:=FloatToStr(Now());
end;

end.

Exe file works as follows:

If system date is  00-04-12
=====================
Date             is interpreted as double
82-01-01          66477 (as 2082 year)
00-04-12          36628 (OK)

If system date is 99-04-12
=====================
Date             is interpreted as double
82-01-01         29952(OK)
00-04-01                   2( ?? )

Function Now() always returns correct value;

Can somebody tell me Where do I do a mistake?

    Thanks
            S3awek

 

Re:SetRange() returns empty set if system date >=2000 year (additional info)


Yeah, check to see whether the underlying database is defined to
have dates with YY or YYYY.

Quote
Cabaj S3awomir <bedau...@poczta.onet.pl> wrote in message

news:38f4d01e@dnews...
Quote
> Hi,
> Lately I had to come back to databases and I found something strange in my
> aplication;
> Procedure SetRange() when system date >= 2000 year always returns empty
data
> set. If system date <=1999 year it works correctly.
> ???

> Here are some details that may be helpful to resolve my strange??
problem.
> I use
> System: Windows 98;
> Format of date:yy-mm-dd;
> yy as year (two digits) is interpreted between 1930 and 2029;

> Delphi Client/Server Suite 4.0;
> I work with Paradox7 tables; Field that makes problems is Date type;

> To input date I use TMaskEdit (EditMask:!00/00/00;1;_);
> I noticed, function StrToDate() also don't give back correct value if
system
> date>=2000 year;
> I"ve made very simple program to examine it:

> unit Unit1;

> interface

> uses
>   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
>   StdCtrls, Mask;

> type
>   TForm1 = class(TForm)
>     Label1: TLabel;
>     MaskEdit1: TMaskEdit;
>     Button1: TButton;
>     Label2: TLabel;
>     procedure Button1Click(Sender: TObject);

>   end;

> var
>   Form1: TForm1;

> implementation

> {$R *.DFM}

> procedure TForm1.Button1Click(Sender: TObject);
> var
>    x: TDateTime;
> begin
>      x:=StrToDate(MaskEdit1.Text);
>      Label1.Caption:=FloatToStr(x);
>      Label2.Caption:=FloatToStr(Now());
> end;

> end.

> Exe file works as follows:

> If system date is  00-04-12
> =====================
> Date             is interpreted as double
> 82-01-01          66477 (as 2082 year)
> 00-04-12          36628 (OK)

> If system date is 99-04-12
> =====================
> Date             is interpreted as double
> 82-01-01         29952(OK)
> 00-04-01                   2( ?? )

> Function Now() always returns correct value;

> Can somebody tell me Where do I do a mistake?

>     Thanks
>             S3awek

Re:SetRange() returns empty set if system date >=2000 year (additional info)


Add this to your code where it will get called somewhere near startup:

      TwoDigitYearCenturyWindow := 30;

Paul / ColumbuSoft
www.columbusoft.com

Quote
Cabaj S3awomir <bedau...@poczta.onet.pl> wrote in message

news:38f4d01e@dnews...
Quote
> Hi,
> Lately I had to come back to databases and I found something strange in my
> aplication;
> Procedure SetRange() when system date >= 2000 year always returns empty
data
> set. If system date <=1999 year it works correctly.
> ???

> Here are some details that may be helpful to resolve my strange??
problem.
> I use
> System: Windows 98;
> Format of date:yy-mm-dd;
> yy as year (two digits) is interpreted between 1930 and 2029;

> Delphi Client/Server Suite 4.0;
> I work with Paradox7 tables; Field that makes problems is Date type;

> To input date I use TMaskEdit (EditMask:!00/00/00;1;_);
> I noticed, function StrToDate() also don't give back correct value if
system
> date>=2000 year;
> I"ve made very simple program to examine it:

> unit Unit1;

> interface

> uses
>   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
>   StdCtrls, Mask;

> type
>   TForm1 = class(TForm)
>     Label1: TLabel;
>     MaskEdit1: TMaskEdit;
>     Button1: TButton;
>     Label2: TLabel;
>     procedure Button1Click(Sender: TObject);

>   end;

> var
>   Form1: TForm1;

> implementation

> {$R *.DFM}

> procedure TForm1.Button1Click(Sender: TObject);
> var
>    x: TDateTime;
> begin
>      x:=StrToDate(MaskEdit1.Text);
>      Label1.Caption:=FloatToStr(x);
>      Label2.Caption:=FloatToStr(Now());
> end;

> end.

> Exe file works as follows:

> If system date is  00-04-12
> =====================
> Date             is interpreted as double
> 82-01-01          66477 (as 2082 year)
> 00-04-12          36628 (OK)

> If system date is 99-04-12
> =====================
> Date             is interpreted as double
> 82-01-01         29952(OK)
> 00-04-01                   2( ?? )

> Function Now() always returns correct value;

> Can somebody tell me Where do I do a mistake?

>     Thanks
>             S3awek

Re:SetRange() returns empty set if system date >=2000 year (additional info)


Quote
>Here are some details that may be helpful to resolve my strange??  problem.
>I use
>System: Windows 98;
>Format of date:yy-mm-dd;
>yy as year (two digits) is interpreted between 1930 and 2029;

>Delphi Client/Server Suite 4.0;
>I work with Paradox7 tables; Field that makes problems is Date type;

try updating your BDE to 5.1

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:SetRange() returns empty set if system date >=2000 year (additional info)


Paul Ferrara napisa3(a) w wiadomo?ci: <8d3bpb$t...@bornews.borland.com>...

Quote
>Add this to your code where it will get called somewhere near startup:

>      TwoDigitYearCenturyWindow := 30;

>Paul / ColumbuSoft
>www.columbusoft.com

Realy, It Works!
    Thanks Paul;

Regards,
=======
           S3awek

Other Threads