'How to get day, month and year as integers from MonthCalendar in Windows Forms?

I have MaxSelectionCount set to 1. I know how to get a date as a string, but I want to have day, month and year as three different variables.



Solution 1:[1]

You can access the date as follows:

var startDate = monthCalendar1.SelectionRange.Start;

The returned property is of type DateTime. Therefore, you can use startDate.Day, startDate.Month or startDate.Year to access the date properties.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Axel Kemper