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
retepAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JoeBoothCommented:
The date value actually holds both a date and time portion.  If you are only interested in the date, use

TRUNC(DateTimePicker1.Date) =
TRUNC(DateTimePicker2.Date)

This tells Delphi to ignore the time portion of the date variable.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IndefreiCommented:
try something like
Label1.Caption := DateToStr(dateTimePicker1.Date);
Label2.Caption := DateToStr(dateTimePicker2.Date);
and compare the labels
(yet not tested)
Indi
0
retepAuthor Commented:
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

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.