OCLOperators Hours
.Hours returns the hours part of a TimeSpan as a whole number from 0 to 23 (-23 to 0 for a negative TimeSpan). Whole days are not included; for that use TotalHours.
Syntax
aTimeSpan.Hours
Returns
Integer
Example
(DateTime.Parse('2026-11-23 14:30:00.250') - DateTime.Parse('2026-11-20 08:15:30')).Hours
Result: 6
The TimeSpan is 3.06:14:30.250. .Hours returns only the 6; the 3 days are not included.
Common pattern
Show a duration as "days and hours":
let ts = DateTime.Now - self.UpdatedOn in
ts.Days.ToString + ' days ' + ts.Hours.ToString + ' hours'
Notes
- A negative TimeSpan gives a negative result:
(DateTime.Parse('2026-11-20') - DateTime.Parse('2026-11-23 06:00')).Hoursreturns-6.
