Jump to content

TUniDateTimePicker, TUniDBDateTimePicker null date - 30/12/1899


tappatappa

Recommended Posts

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?

Link to comment
Share on other sites

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?  

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...