Search code examples
c#datetimedate-mathdate-manipulation

Return start and end of year given any year


I need two or one (out) C# method that will take any datetime and return the start date of year and end date of year for that year.


Solution

  • void Dates(DateTime d, out DateTime b, out DateTime e)
    {
        b = new DateTime(d.Year, 1, 1);
        e = new DateTime(d.Year, 12, 31);
    }