A
A
Alexey Smirnov2018-03-07 02:04:43
.NET
Alexey Smirnov, 2018-03-07 02:04:43

How to count the number of days until the nearest 25th day (of a month) in C#.NET?

It is necessary to count the number of days until the nearest 25th.
That is, if today is the 20th (of any month), then the program will display the number 5.
If today is the 28th and this month has 30 days, then the program will display the number 27 (2 days before the 30th + 25 days).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Arxont, 2018-03-07
@ERAFY

static int DaysTill25(DateTime dt)
{
   return dt.Day <= 25 ? 
                       25 - dt.Day
                     : 25 + (DateTime.DaysInMonth(dt.Year, dt.Month) - dt.Day);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question