OCLOperators TotalDays
.TotalDays returns the whole length of a TimeSpan in days, as a decimal number. The fractional part holds the leftover hours, minutes, seconds and milliseconds.
Syntax
aTimeSpan.TotalDays
Returns
Double
Example
(DateTime.Parse('2026-11-23 14:30:00.250') - DateTime.Parse('2026-11-20 08:15:30')).TotalDays
Result: 3.26007233796296
The TimeSpan here is 3.06:14:30.250 (3 days, 6 hours, 14 minutes, 30.25 seconds). .TotalDays folds all of it into one number of days.
Model example
Days since an employee was hired, in the context of Employee:
(DateTime.Today - self.HireDate).TotalDays
Notes
- If the first date comes before the second, the TimeSpan is negative and so is the result. For example,
(DateTime.Parse('2026-11-20') - DateTime.Parse('2026-11-23 06:00')).TotalDaysreturns-3.25. - To get whole days only, use Days.
