Link to home
Start Free TrialLog in
Avatar of retep
retep

asked on

Comparing TDates???

I have a serious problem!!! I need to compare two dates of TDate, but can't seem to make it work :-(

For instance I tried this:

procedure TForm1.Button1Click(Sender: TObject);
begin
  If dateTimePicker1.Date = dateTimePicker2.Date then
    Showmessage('The same')
  else
    showmessage('not the same');
end;

And no matter if I gave them the same dates or different dates, the answer was 'Not the same' :-(



I also tried to typecast into double, but also with no luck.

Please help!!! It is very important for me since it is a big part of a schoolproject which deadline is coming closer in an eksponential rate (or so it seems :-)

Thanks
Retep
ASKER CERTIFIED SOLUTION
Avatar of JoeBooth
JoeBooth

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Indefrei
Indefrei

try something like
Label1.Caption := DateToStr(dateTimePicker1.Date);
Label2.Caption := DateToStr(dateTimePicker2.Date);
and compare the labels
(yet not tested)
Indi
Avatar of retep

ASKER

Thanks JoeBooth. Excatly what I was looking for! Now I'm very happy, and can get on with my project... :-)

Indefrei>> Before I posted this question I tried DateToStr, but soon discovered that using the DateToStr solution was not very Y2K-proof, since it only uses two digits...

Thanks to both of U.
Retep