How to calculate days, ignoring the hours?

Asked

Viewed 253 times

3

How can I calculate if spent 1 day ignoring the hours. Explaining, it would be more or less like this:

I have a date 2017-09-09 11:45:20, normally it would have been a day when the 11:45 the other day, but I’d like it to count as 1 day as soon as it 00:00:00.

Even though I have the following date 2017-09-09 23:59:59 and now was 2017-09-10 00:00:00. Literally just went by 1 minute, but I want you to tell me how 1 day.

I tried to do it this way, but I returned 0:

//                          mês/dia/ano hora:min:seg
// questData.CompletedDate   09/09/2017 11:45:20
// DateTime.Today            09/10/2017 00:00:00
int totalDays = (int)DateTime.Today.Subtract(questData.CompletedDate).TotalDays;

How to do this in C#?

1 answer

5


Browser other questions tagged

You are not signed in. Login or sign up in order to post.