Indicate how many days in the future will be the date and time.

I have this DateTime object:

model.Model.Results.FloatingComponent().Schedule.ScheduleRows[0].Payment.FromDate.AdjustedDate

How to find out how many days in the future if this happens in the future?

+3
source share
3 answers
TimeSpan delta = Foo.AdjustedDate - DateTime.Now;

if(delta.Days > 0)
{
  //...
}

Edit:

Based on @Gabe, comment on a version here that only looks at days:

TimeSpan delta = Foo.AdjustedDate.Date - DateTime.Today;

if(delta.Days > 0)
{
  //...
}
+7
source
DateTime mydate = ....

TimeSpan span = mydate.Subtract(DateTime.Now);

// then use span.Days;
0
source
int days = (futureDate - DateTime.Today).Days;
0
source

Source: https://habr.com/ru/post/1796134/


All Articles