Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Win 32 Controls/TDateTimePicker    [ Add a report in this area ]  
Report #:  47614   Status: Open
TDateTimePicker Date property returns a time portion even though it is not documented to do so
Project:  Delphi Build #:  11.0.2627.5503
Version:    11.0 Submitted By:   Eivind Bakkestuen
Report Type:  Minor failure / Design problem Date Reported:  6/15/2007 6:15:30 PM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   252556
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 4
Description
The documentation of this property talks about setting *date*, it says nothing about a time portion. Since there is also a DateTime property, it is obvious that Date was supposed to return only the Date portiion.

If users rely on the docs, they will incorrectly assume that using Date will return a 0 time portion (ie midnight). This will for instance cause sql datasets to return wrong records if a datepicker.Date value is used to select a range of records.

It would seem that whoever created the TCommonCalendar.Date property get method forgot that a  cast to TDate doesnt really do anything useful to the value. The function should remove the time portion too.

function TCommonCalendar.GetDate: TDate;
begin
  Result := TDate(FDateTime);
end;
Steps to Reproduce:
Use TDateTimePicker.Date; observe the Time portion is whatever the hour of day happens to be when the function is called. This is not how one would expect a Date value to work.
Workarounds
using Trunc() on the returned value works around the problem.
Attachment
None
Comments

None

Server Response from: ETNACODE01