Board index » delphi » How to validate a DATE?

How to validate a DATE?

Hi,
I new a function like IsDate(sParam: String): boolean;
Any ideas,

Thanks
Antonio

 

Re:How to validate a DATE?


function IsValidDate(Adate: String): boolean;
begin
 result := true;
  try
    StrToDate(Adate);
  except
    // showmessage('Date is not valid.');
    result := false;
  end;
end;

tom

Quote
Antonio <anto...@gmsourcefl.com> wrote in message

news:8u6g6l$j1k3@bornews.borland.com...
Quote
> Hi,
> I new a function like IsDate(sParam: String): boolean;
> Any ideas,

> Thanks
> Antonio

Re:How to validate a DATE?


function IsValidDate(Adate: String): boolean;
begin
 result := true;
  try
    StrToDate(Adate);
  except
    on EConvertError do
    begin
      result := false;
      // showmessage('Date is not valid.');
    end;
  end;
end;

Might be a good idea to use the EConvertError exception so that the
function is not confused when the conversion fails for any other reason
:)

JB

Quote

> > Thanks
> > Antonio

Other Threads