-1

I have to calculate number of days difference between today and SubmittedDate, but if I the SubmittedDate = today my Result = 0,430090... Instead of 1

here is my code:

 DaysDiff = (today.Subtract(DataUtilities.GetSafeDateTime(financialStatement[SharePoint_Assessment_Fields.SUBMITTEDDATE_FIELD]))).TotalDays,

could you please help me ?

BKChedlia
  • 327
  • 2
  • 4
  • 18

1 Answers1

2

The TotalDays property is a double. It also takes the hours and minutes in account, so that might cause the subtraction of two days get fractions too.

If you want to round that, you could use Math.Round, Math.Ceiling or Math.Floor depending on your needs. Taking your expected outcome, I guess you need to use Ceiling:

double ceiledDays = Math.Ceiling(ts.TotalDays);

Or you could get the Date part of the two dates and calculate with that.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325