How to get current year from a date in C# – Programming Code Examples
ASP.NET C#

How to get current year from a date in C#2 min read

The following asp.net c# example code demonstrate us how can we get the Year component (year part) from a DateTime object programatically at run time. .Net framework’s DateTime.Year property allow us to get the year component of the date represented by this instance.

.Net framework’s DateTime.Year property exists in System namespace. This property return value data type is System.Int32. This return integer number represent the year of DateTime instance. The return year number is between 1 to 9999.




DateTime.Year property return the year of the DateTime instance in the Gregorian Calendar. The bellow image describe us this tutorial more easily.

 

How to get year from a date in C#

How to get year from a date in C#

 

ASP.NET Code:

 

Leave a Comment