I'm really confused. What I want to do (seems pretty simple) is to display a date + time in a TDateTimePicker, with the calendar integrated, and be able to read it after its value has changed.
I'd like to use the dd/MM/yyyy hh:mm format.
Since the TDateTimePicker isn't a TDateOrTimePicker, a used one with :
- Kind : dtkDate (displays the calendar)
- Format : 'dd/MM/yyyy hh:mm'
Looks good, now let's read it :
showmessage(DateTimeToStr(DateTimePicker1.Date));
Only displays the date correctly. Changes on the hh:mm part is not taken into account. I always get the default value. Then I thought : There is also a Time property, maybe I need to read the value in 2 times.
showmessage(DateTimeToStr(DateTimePicker1.Time));
showmessage(DateTimeToStr(DateTimePicker1.Date));
But I have the exact same output (and problem) as before. So now, let's try to change this Kind property to dtkTime, then read the time, then switch it back to dtkDate then read the date.
But no, it still doesn't work. Switching the Kind property from dtkDate to dtkTime erases my input on the hh:mm part.
I know I'm actually supposed to work with 2 TDateTimePickers : one for the date, one for the time.
So my question is :
- Is there an easy way to solve my simple and very common problem (a real DateTimePicker) ?
And a Delphi design questions :
- Why is there a Format property that is basically useless and misleading ? Having a TimeFormat, DateFormat, and proper format validation process isn't that hard.
Please note that I post this question mainly to avoid beginners doing the same loooong process of debugging and frustration.