I would like to get the total number of days in a year left from the given date .. Assume if a user gives 04-01-2011(MM-DD-YYYY)
I would like to find the remaining days left. How to do this..
To calculate the number of days between two dates, you need to subtract the start date from the end date.
To find the number of days between these two dates, you can enter “=B2-B1” (without the quotes into cell B3). Once you hit enter, Excel will automatically calculate the number of days between the two dates entered.
So to correct (approximately), we add 1 day every four years (leap year). Thus, three calendar years are 365 days long; the fourth calendar year is 366 days long. The average length of the calendar year in days now becomes: (3 x 365 + 366)/4 = 365.25 days.
Perhaps just:
DateTime.IsLeapYear(DateTime.Now.Year) ? 366 : 365
Sorry, read it as if you just wanted the number of days in current year...
should do the trick
int daysLeft = new DateTime(DateTime.Now.Year, 12, 31).DayOfYear - DateTime.Now.DayOfYear;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With