[DUG] DateTimePicker
When a TDateTime is set from a DateTimePicker that is being used for Date selections what is set for the time component? Or is it random? I am wondering because two different pickers seem to return unrelated times and it looks like I have to do some testing and correcting. And for testing - I think that a test such as if DatePicker1.date = date then.. might not be a reliable test (if both are effectively floating point) This is D5 in case later versions have smarter testing John ___ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe
Re: [DUG] DateTimePicker
TDateTimePicker internally initialises its DateTime to Now - changes to the date-part of the value presumably do not alter the time-part (unless modifying date AND time via the DateTime value). The different time-parts in your pickers presumably reflects different constructor execution times (yielding slightly different Now() results and therefore different time-part values). Two ways (at least) to skin this particular feline spring to mind: 1. If you only ever work with the Date of these pickers, you could initialise each to a known, consistent time-value (this then shouldn't change unless you subsequently change the time-value in some other way) 2. Specifically exclude the time-part by Trunc()'ing the Date in any comparisons. The Date property itself only does a hard-typecast, not a conversion and since TDate is simply a distinct-type alias for TDateTime this merely propagates and preserves the time-part of the underlying datetime into the supposedly date only TDate value. Hope that helps. -Original Message- From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On Behalf Of John Bird Sent: Tuesday, 29 June 2010 13:42 To: NZ Borland Developers Group - Delphi List Subject: [DUG] DateTimePicker When a TDateTime is set from a DateTimePicker that is being used for Date selections what is set for the time component? Or is it random? I am wondering because two different pickers seem to return unrelated times and it looks like I have to do some testing and correcting. And for testing - I think that a test such as if DatePicker1.date = date then.. might not be a reliable test (if both are effectively floating point) This is D5 in case later versions have smarter testing John ___ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe ___ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe
Re: [DUG] DateTimePicker
If you are only interested in the Date part of the TDateTime you could always use the Trunc function. ie. if Trunc(DatePicker1.Date) = Date then... Cheers, Colin On 29 June 2010 11:42, John Bird johnkb...@paradise.net.nz wrote: When a TDateTime is set from a DateTimePicker that is being used for Date selections what is set for the time component? Or is it random? I am wondering because two different pickers seem to return unrelated times and it looks like I have to do some testing and correcting. And for testing - I think that a test such as if DatePicker1.date = date then.. might not be a reliable test (if both are effectively floating point) This is D5 in case later versions have smarter testing John ___ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe ___ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe
Re: [DUG] DateTimePicker
in my experience, the DatePicker1.date only returns the date part of the date in the control i.e. no time portion. If you want to be double sure you can do DateOf(DatePicker1.Date) Jeremy On Tue, Jun 29, 2010 at 2:20 PM, Colin Johnsun colin.a...@gmail.com wrote: If you are only interested in the Date part of the TDateTime you could always use the Trunc function. ie. if Trunc(DatePicker1.Date) = Date then... Cheers, Colin On 29 June 2010 11:42, John Bird johnkb...@paradise.net.nz wrote: When a TDateTime is set from a DateTimePicker that is being used for Date selections what is set for the time component? Or is it random? I am wondering because two different pickers seem to return unrelated times and it looks like I have to do some testing and correcting. And for testing - I think that a test such as if DatePicker1.date = date then.. might not be a reliable test (if both are effectively floating point) This is D5 in case later versions have smarter testing John ___ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe ___ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe ___ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe