Mega Code Archive

 
Categories / Delphi / Forms
 

DateTimePicker Format

Title: DateTimePicker Format Question: How can I format the date in a datetimepicker ? Answer: ever wonder why the DateTimePicker in the VB has a date format, while in Delphi, it does not !! NO PROBLEM.. Place a Datetimepicker component in your form , and use the unit "Commctrl". Then Try this code: procedure TForm1.Button2Click(Sender: TObject); Var DFormat : String; begin DFormat := 'dd-MM-yyyy'; // BE CAREFULL: the "MM" should be capital letters DateTimePicker1.Perform ( DTM_SETFORMAT , DWORD(NIL) , DWORD(DFormat) ); { // Try these formats: DFormat := 'dd-MMM-yyyy'; DFormat := 'dd-MMMM-yyyy'; DFormat := 'dd-MMMM-yyyy'; DFormat := 'HH:mm'; DFormat := 'hh:mm tt'; DFormat := 'dd-MMM-yyyy'; DFormat := 'dd-MM-yyyy HH:mm'; } // NOTE: This code was tested on deplhi 4, Windows NT workstation 4 end;