tappatappa Posted April 30, 2013 Posted April 30, 2013 I have an annoying problem, which seems to be quite popular in many Frameworks. I am writing an application that loads records from a database where, in general, datetime data (timestamps) are nullable. When I display null values using a DateTimePicker i get "30/12/1899" which is an awful default for NULL. All I want is a blank DateTimePicker Field. So far, the only (not) acceptable workaround I've found is to change the dateformat to " / / " in case of nulls and then reset it to default when the user (or some automatic routine) changes the value to some valid datetime. Something like: void __fastcall TFormMain::UniDateTimePicker1Change(TObject *Sender) { if(UniDateTimePicker1->DateTime==0.0){ UniDateTimePicker1->DateFormat=L" / / "; }else{ UniDateTimePicker1->DateFormat=L"dd/MM/yyyy"; } } Following this approach, I have to intercept all the events (not only OnChange) that may trigger from any datetimepicker component that I put in my application. I do not wish to do that, because I am a lazy programmer :| Any ideas? Quote
Administrators Farshad Mohajeri Posted April 30, 2013 Administrators Posted April 30, 2013 Setting DateTimepicker to zero ( 0.0) will show a blank date. Quote
tappatappa Posted May 2, 2013 Author Posted May 2, 2013 Thanks Farshad, setting UniDateTimePicker->DateTime to 0.0 shows a blank date. But this does not seem to work with UniDBDateTimePicker. I tried to manually set the corresponding data field to 0.0, but the component keeps showing 30/12/1899. Can you tell me why? Quote
Administrators Farshad Mohajeri Posted May 2, 2013 Administrators Posted May 2, 2013 Please add a Feature Request. Quote
tappatappa Posted May 6, 2013 Author Posted May 6, 2013 ShowBlankDate = true solved the problem. But I've found a bug concerning blank date fields (Bug Report soon..) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.