How to get month from a date in C# – Programming Code Examples
C# C# Console Application

How to get month from a date in C#1 min read

The following example code demonstrate us how can we get the month part/component from a dateTime object programmatically at run time. .Net framework’s DateTime.Month property allow us to get the month part of the date represented by this instance. DateTime is exists in .Net Framework’s System namespace.

DateTime.Month property return a System.Int32 data type value. This return integer number represent the month component of the provided DateTime instance. This return integer value is a number between 1 to 12 where 1 represent January, 2 represent February and so on. The provided output image help you more to better understand this tutorial.




C# Code:

Output:

How to get month from a date in C#

How to get month from a date in C#

Leave a Comment