Articles in this section
Category / Section

How to customize the DateTime format in the DateTimePickerAdv?

2 mins read

You can customize the Date and Time display format in the WinForms DateTimePicker by using Format property. The types of display format are,

  1. Long
  2. Short
  3. Time
  4. Custom

 

Long: It helps to display the date/time value in the long date.

Short: It helps to display the date/time value in the short date.

Time: It helps to display the date/time value in the time date.

Custom: It helps to display the date/time value in custom format. 

 

The following code example demonstrates the same.

C#

//Displays the date/time value in the long date format.
this.dateTimePickerAdv1.Format = System.Windows.Forms.DateTimePickerFormat.Long;
//Displays the date/time value in the short date format.
this.dateTimePickerAdv1.Format = System.Windows.Forms.DateTimePickerFormat.Short;
//Displays the date/time value in the time format.
this.dateTimePickerAdv1.Format = System.Windows.Forms.DateTimePickerFormat.Time;
//Displays the date/time value in a custom format.
this.dateTimePickerAdv1.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
//Sets the date/time format of the picker when Format is Custom.
this.dateTimePickerAdv1.CustomFormat = "MMMM/yyyy";

 

VB

'Displays the date/time value in the long date format.
Me.dateTimePickerAdv1.Format = System.Windows.Forms.DateTimePickerFormat.Long
'Displays the date/time value in the short date format.
Me.dateTimePickerAdv1.Format = System.Windows.Forms.DateTimePickerFormat.Short
'Displays the date/time value in the time format. 
Me.dateTimePickerAdv1.Format = System.Windows.Forms.DateTimePickerFormat.Time
'Displays the date/time value in a custom format.
Me.dateTimePickerAdv1.Format = System.Windows.Forms.DateTimePickerFormat.Custom
'Sets the date/time format of the picker when Format is Custom.
Me.dateTimePickerAdv1.CustomFormat = "MMMM/yyyy"

 

The following screenshots display the different formats of the DateTimePickerAdv.

 

Showing Long date format in WinForms DateTimePicker

Figure 1: DateTimePickerAdv specified with Format.Long

 

Showing short date format in WinForms DateTimePicker

Figure 2: DateTimePickerAdv specified with Format.Short

Showing Time format in WinForms DateTimePicker

Figure 3: DateTimePickerAdv specified with Format.Time

Showing custom format in WinForms DateTimePicker

Figure 4: DateTimePickerAdv specified with Custom Format

Sample Links:

C#: DateTimePickerAdv_Format_C#

VB: DateTimePickerAdv_Format_VB

Conclusion

I hope you enjoyed learning about how to customize the DateTime format in the DateTimePickerAdv.

You can refer to our WinForms DateTimePicker’s feature tour page to know about its other groundbreaking feature representations.

For current customers, you can check out our WinForms from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms DateTimePicker and other WinForms components.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied