docs / articles / Add Microsoft Date and Time Picker Control

Add Microsoft Date and Time Picker Control

Eric Jul 09, 2026 2026-07-09 04:40:47

Streamlining your applications with intuitive user interfaces often involves incorporating date and time pickers. Microsoft's DateTimePicker control, part of its WinForms library, simplifies this process. Let's delve into how to add and customize this control to enhance your user experience.

Microsoft Date and Time Picker Control - How To Enable and Use It
Microsoft Date and Time Picker Control - How To Enable and Use It

Before we dive in, ensure you have the necessary prerequisites. You'll need a development environment set up for WinForms, such as Visual Studio, and a basic understanding of C# programming.

Excel VBA USERFORMS #25 Date Picker Calendar revealed! Loop through Userforms and Controls  Example
Excel VBA USERFORMS #25 Date Picker Calendar revealed! Loop through Userforms and Controls Example

Adding Microsoft DateTimePicker Control

The first step is to include the DateTimePicker control in your project. This can be done via the Toolbox in Visual Studio or by manually adding it through code.

How to Add an Updating Date and Time in Microsoft Word (PC & Mac)
How to Add an Updating Date and Time in Microsoft Word (PC & Mac)

Here's how you can add it via the Toolbox:

  • Open your form in design view.
  • Locate the 'DateTimePicker' component in the Toolbox (under 'Common Controls').
  • Drag and drop it onto your form.
How to Add Date Picker Calendar Drop Down in MS Excel (Easy)
How to Add Date Picker Calendar Drop Down in MS Excel (Easy)

Adding via Code

Alternatively, you can add the DateTimePicker control programmatically. Here's a simple example:

DateTimePicker dtp = new DateTimePicker();

Excel Date Picker - How to Insert? (Step by Step Examples)
Excel Date Picker - How to Insert? (Step by Step Examples)

Then, you can set its properties and add it to your form's controls collection:

dtp.Format = DateTimePickerFormat.Short; // Set the date format

this.Controls.Add(dtp);

Designing The Perfect Date And Time Picker — Smashing Magazine
Designing The Perfect Date And Time Picker — Smashing Magazine

Setting Initial Date and Time

You can set the initial date and time using the 'Value' property:

How to Quickly Insert Date And Time In Excel
How to Quickly Insert Date And Time In Excel
the date picker app is displayed on an iphone's screen, with time remaining
the date picker app is displayed on an iphone's screen, with time remaining
302K views · 10K reactions | How to insert a calendar and date picker in Excel‼️ 🗂️ Don’t forget to save this post! 🧑‍🏫 Get your FREE Excel templates with the link in our bio! 🤯 Follow us on TikTok, YouTube, Twit | CheatSheets
302K views · 10K reactions | How to insert a calendar and date picker in Excel‼️ 🗂️ Don’t forget to save this post! 🧑‍🏫 Get your FREE Excel templates with the link in our bio! 🤯 Follow us on TikTok, YouTube, Twit | CheatSheets
MS Outlook Calendar: How to Add, Share, & Use It Right | Envato Tuts+
MS Outlook Calendar: How to Add, Share, & Use It Right | Envato Tuts+
Responsive Time Picker UI Design with HTML CSS JavaScript Free Download  Modern Dark Theme
Responsive Time Picker UI Design with HTML CSS JavaScript Free Download Modern Dark Theme
How do I revert back to the (old) numerical date & time pickers?
How do I revert back to the (old) numerical date & time pickers?
Mastering Excel Date & Time: Serial numbers, Networkdays, Datevalue, and more
Mastering Excel Date & Time: Serial numbers, Networkdays, Datevalue, and more
Calculate days from/before date in Excel
Calculate days from/before date in Excel
Never waste time typing out dates again with this calendar tool. 🗓
Never waste time typing out dates again with this calendar tool. 🗓
the date and time functions in excel, with instructions to use it for each task
the date and time functions in excel, with instructions to use it for each task
Perfect Inserting A Dropdown Calendar In Excel
Perfect Inserting A Dropdown Calendar In Excel
Mini Nerdle Game: How to Enable and Play It
Mini Nerdle Game: How to Enable and Play It
How to Add Dates in Excel Automatically (2 Simple Steps)
How to Add Dates in Excel Automatically (2 Simple Steps)
How to create a date picker in Excel!🙏
How to create a date picker in Excel!🙏
Change the Regional Date and Time Format [How To]
Change the Regional Date and Time Format [How To]
NEW Date Picker in Excel for Web – Finally Here
NEW Date Picker in Excel for Web – Finally Here
How to Postpone Email in Outlook for iOS on Your Schedule
How to Postpone Email in Outlook for iOS on Your Schedule
the format tab in microsoft's office window is highlighted by an arrow pointing to the date
the format tab in microsoft's office window is highlighted by an arrow pointing to the date
the excel time and date sheet
the excel time and date sheet
How to Use Excel UserForm as Date Picker (with Easy Steps) - ExcelDemy
How to Use Excel UserForm as Date Picker (with Easy Steps) - ExcelDemy

dtp.Value = new DateTime(2022, 12, 31); // Set the initial date to December 31, 2022

Customizing DateTimePicker Control

Once added, you can customize the DateTimePicker control to fit your application's needs. Let's explore some customization options.

Changing the Date Format

The 'Format' property determines how the date is displayed. It can be set to 'Short', 'Long', 'Custom', or 'Time'.

dtp.Format = DateTimePickerFormat.Custom; // Set the format to custom

Then, you can set the custom format string:

dtp.CustomFormat = "dd/MM/yyyy"; // Set the custom format to dd/MM/yyyy

Disabling Certain Dates

You can disable certain dates using the 'Enabled' property of the 'DateTimePicker' control. This can be useful for preventing users from selecting dates in the past or future.

Here's an example of disabling dates in the past:

dtp.MinDate = DateTime.Today; // Set the minimum selectable date to today

To encourage users to explore and interact with your application, ensure your DateTimePicker controls are intuitive and user-friendly. Regularly test and iterate on your designs to create the best possible user experience.