Question

This question already has an answer here:

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.

Was it helpful?

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);
}

OTHER TIPS

DateTime startDate = new DateTime(year, 1, 1);
DateTime endDate = new DateTime(year, 12, 31);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top