Search code examples
c#date

How to get the first day and the last day of the current year in c#


How do I get the first day and the last day of the current year in c#


Solution

  • This?

    int year = DateTime.Now.Year;
    DateTime firstDay = new DateTime(year, 1, 1);
    DateTime lastDay = new DateTime(year, 12, 31);