Forum Discussion
Dicken
Post Prodigy
1 month agocreate total hours from date time
- 1 month ago
Hi Dicken
try sample mcode
let Source = #table( type table [Task = text, Start = datetime, End = datetime], { {"Task A", #datetime(2026, 10, 1, 9, 0, 0), #datetime(2026, 10, 1, 17, 30, 0)}, {"Task B", #datetime(2026, 10, 1, 22, 0, 0), #datetime(2026, 10, 2, 6, 15, 0)}, {"Task C", #datetime(2026, 10, 2, 8, 0, 0), #datetime(2026, 10, 5, 12, 0, 0)}, {"Task D", #datetime(2026, 10, 3, 14, 45, 0), #datetime(2026, 10, 3, 15, 5, 0)}, {"Task E", #datetime(2026, 10, 4, 10, 0, 0), null} } ), AddTotalHours = Table.AddColumn( Source, "Total Hours", each if [Start] = null or [End] = null then null else Number.Round(Duration.TotalHours([End] - [Start]), 2), type number ) in AddTotalHoursPlease give kudos or mark it as resolved once confirmed.
Regards,
Praful
Murtaza_Ghafoor
Super User
1 month agoDicken
You need these two fields in your table
- StartDateTime
- EndDateTime
Go to Add Column → Custom Column and use:
Duration.TotalHours([EndDateTime] - [StartDateTime])
Example:
| StartDateTime | EndDateTime | Total Hours |
|---|---|---|
| 29-Sep-2026 08:00 | 29-Sep-2026 17:30 | 9.5 |
| 29-Sep-2026 09:15 | 30-Sep-2026 10:15 | 25 |
If this helps, ✓ Mark as Kudos | Help Other