Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Display Blank Date in a TDateTimePicker 1

Status
Not open for further replies.

Pontelo

Programmer
Dec 18, 2001
80
BR
Hi people,
pls how do we display a blank date in this component ?
For default it display 12/29/1899 !
Tks in advance !
 
well i don't think you can blank out the date in a tDateTimePicker but what you can do is set the ShowCheckBox property to true which you can use to check if a date value has been entered. hope that helps.
 
Delfy is probably correct - Delphi is Pascal and will set any uninitialised variable to a random value normally. Components such as DateTimePicker can't allow this to happen, so will default to the earliest date they can use in the system - usually the end of the 19th century (depending on your MaxDate & MinDate settings).
You can always set the date to something meaningful - such as today, or 1-Jan-1900:
Code:
  MyDatePicker.Date := now();
  MyDatePicker.Date := encodedate(MyYear, MyMonth, MyDay);

Hope thats of value....

Cheers,
Chris [pc2]
 
People Tks to returning.
We used a component from RXLib (TDateEdit) that solved the problem. Our system stores dates as strings. A little code was needed.
 
Have you tried the following:

Code:
   with DateTimePicker1 do
   begin
       if DateTime=0 then
          DateTime_SetFormat(Handle, 'gg')
       else
          DateTime_SetFormat(Handle, '');
   end;



"It is in our collective behaviour that we are most mysterious" Lewis Thomas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top