Find the last day of the year

Bibi Tahira picture Bibi Tahira · Sep 5, 2013 · Viewed 20.4k times · Source

I am doing a task in which it is required to find the last day of the year by given current date.

Like if its 06/Jan/2013 is given to it and it will automatically return the end day of the year. like 31/Dec/2013

I am using many ways like adding the remaining days of the year, but when it is Leap year then miss matches occurs, can any body send me precise solution or guied me how to.

Basically I wanted to jump over the last date of the year.This was tentively for C#

Answer

dcastro picture dcastro · Sep 5, 2013

Why not something simple like this?

var date = new DateTime(2013, 1,6);
var lastDayOfTheYear = new DateTime(date.Year, 12, 31);