How to get the number of days in a given month in C# – Programming Code Examples
ASP.NET C#

How to get the number of days in a given month in C#2 min read

DateTime.DaysInMonth() method return the number of days in the specified month and year. this method exists in System namespace. DateTime.DaysInMonth(year, month) method require to pass two parameters named ‘year’ and ‘month’. the ‘year’ parameter value data type is System.Int32 which represent the specified year. the ‘month’ parameter value data type also System.int32 which represent a month number ranging from 1 to 12.

this method return value data type is System.Int32 which represent the number of days in specified month for the specified year. this is very useful method to get the number of days in February month in a specified year which depend on leap year.




the following asp.net c# example code demonstrate us how can we get days (count number of days) in a specified month and year programmatically at run time in an asp.net application.

How to get the number of days in a given month in C#

How to get the number of days in a given month in C#

ASP.NET Code:

 

Leave a Comment