Duration in Years - Month - Days - Hours - Minutes

shah_ir85

New Member
Joined
May 8, 2016
Messages
40
Hey mate....please help me

i have to calculate duration for 2 date and time. Please help me with the formula on C.

For example

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]Start
[/TD]
[TD]End
[/TD]
[TD]Duration
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]1 Jan 16 13:30
[/TD]
[TD]3 Apr 17 23:45
[/TD]
[TD]1 Year 3 Month 2 Days 10 Hours 15 Minutes
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]1 Apr 15 12:40
[/TD]
[TD]1 May 17 13:45
[/TD]
[TD]2 Years 1 Month 1 Hour 5 Minutes
[/TD]
[/TR]
</tbody>[/TABLE]

Please help me if you can tQ
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi,

try this:


Book1
ABCDE
1
2StartEndDuration
31-1-2016 13:303-4-2017 23:451 Year 3 Month 2 Days 10 Hours 15 Minutes1 Year 3 Months 2 Days 10 Hours 15 Minutes
41-4-2015 12:401-5-2017 13:452 Years 1 Month 1 Hour 5 Min2 Years 1 Month 1 Hour 5 Minutes
Sheet2
Cell Formulas
RangeFormula
E3=IF(DATEDIF(A3,B3,"y")=0,"",DATEDIF(A3,B3,"y")&LOOKUP(DATEDIF(A3,B3,"y"),{0,2},{" Year "," Years "}))&IF(DATEDIF(A3,B3,"ym")=0,"", DATEDIF(A3,B3,"ym")&LOOKUP(DATEDIF(A3,B3,"ym"),{0,2},{" Month "," Months "}))&IF(DATEDIF(A3,B3,"md")=0,"", DATEDIF(A3,B3,"md")&LOOKUP(DATEDIF(A3,B3,"md"),{0,2},{" Day "," Days "}))&IF(HOUR(MOD(B3,1)+(MOD(A3,1)>MOD(B3,1))-MOD(A3,1))=0,"",HOUR(MOD(B3,1)+(MOD(A3,1)>MOD(B3,1))-MOD(A3,1))&LOOKUP(HOUR(MOD(B3,1)+(MOD(A3,1)>MOD(B3,1))-MOD(A3,1)),{0,2},{" Hour "," Hours "}))&IF(MINUTE(MOD(B3,1)+(MOD(A3,1)>MOD(B3,1))-MOD(A3,1))=0,"",MINUTE(MOD(B3,1)+(MOD(A3,1)>MOD(B3,1))-MOD(A3,1))&LOOKUP(MINUTE(MOD(B3,1)+(MOD(A3,1)>MOD(B3,1))-MOD(A3,1)),{0,2},{" Minute "," Minutes "}))
 
Last edited:
Upvote 0
hey mate...sorry again...error occur for example

start date 6 Aug 17 2230
end date 8 Aug 17 1445

duration 2 Days 16 Hours 15 Minutes

Its should be 1 Day 16 Hours 15 Minutes

please help me
 
Upvote 0
custom format d:hh:mm:ss;@


Excel 2010
ABC
16-Aug-178-Aug-171:16:15:00
5f
Cell Formulas
RangeFormula
C1=B1-A1
 
Last edited:
Upvote 0
try this:


Book1
ABCDE
2StartEndDuration
31-1-2016 13:303-4-2017 23:451 Year 3 Month 2 Days 10 Hours 15 Minutes1 Year 3 Months 2 Days 10 Hours 15 Minutes
41-4-2015 12:401-5-2017 13:452 Years 1 Month 1 Hour 5 Min2 Years 1 Month 1 Hour 5 Minutes
56-8-2017 22:308-8-2017 14:451 Day 16 Hours 15 Minutes
66-8-2017 22:308-8-2017 22:312 Days 1 Minute
Sheet1
Cell Formulas
RangeFormula
E3=IF(DATEDIF(A3,B3,"y")=0,"",DATEDIF(A3,B3,"y")&LOOKUP(DATEDIF(A3,B3,"y"),{0,2},{" Year "," Years "}))&IF(DATEDIF(A3,B3,"ym")=0,"", DATEDIF(A3,B3,"ym")&LOOKUP(DATEDIF(A3,B3,"ym"),{0,2},{" Month "," Months "}))&IF(DATEDIF(A3,B3,"md")=0,"", DATEDIF(A3,B3,"md")-IF((MOD(B3,1)A3,1)),1,0)&LOOKUP(DATEDIF(A3,B3,"md")-IF((MOD(B3,1)A3,1)),1,0),{0,2},{" Day "," Days "}))&IF(HOUR(MOD(B3,1)+(MOD(A3,1)>MOD(B3,1))-MOD(A3,1))=0,"",HOUR(MOD(B3,1)+(MOD(A3,1)>MOD(B3,1))-MOD(A3,1))&LOOKUP(HOUR(MOD(B3,1)+(MOD(A3,1)>MOD(B3,1))-MOD(A3,1)),{0,2},{" Hour "," Hours "}))&IF(MINUTE(MOD(B3,1)+(MOD(A3,1)>MOD(B3,1))-MOD(A3,1))=0,"",MINUTE(MOD(B3,1)+(MOD(A3,1)>MOD(B3,1))-MOD(A3,1))&LOOKUP(MINUTE(MOD(B3,1)+(MOD(A3,1)>MOD(B3,1))-MOD(A3,1)),{0,2},{" Minute "," Minutes "}))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top