Forum Discussion
Convert custom date format <day> <hour>:<minute>:<second> to something workable in excel?
- Sep 18, 2019
You have texts, not datetime (which is actually an number in Excel). To receive the difference in seconds you need to parse these texts like
=IFERROR((LEFT(D5,2)-LEFT(C5,2))+RIGHT(D5,8)-RIGHT(C5,8),"")
and apply to the resulting cell [ss] custom format.
IFERROR returns empty string if you have error in result, that happens if one of the texts is empty.
Alternatively you may keep General format and convert result to seconds as
=IFERROR( (LEFT(D5,2)-LEFT(C5,2)+RIGHT(D5,8)-RIGHT(C5,8) )*60*60*24,"")
Please check in attached file.
You have texts, not datetime (which is actually an number in Excel). To receive the difference in seconds you need to parse these texts like
=IFERROR((LEFT(D5,2)-LEFT(C5,2))+RIGHT(D5,8)-RIGHT(C5,8),"")
and apply to the resulting cell [ss] custom format.
IFERROR returns empty string if you have error in result, that happens if one of the texts is empty.
Alternatively you may keep General format and convert result to seconds as
=IFERROR( (LEFT(D5,2)-LEFT(C5,2)+RIGHT(D5,8)-RIGHT(C5,8) )*60*60*24,"")
Please check in attached file.
- Dezmaster2020Feb 26, 2021Copper Contributor
How to deal with negative values in this case? especially when there 24hrs overlap ?
- SergeiBaklanFeb 26, 2021Diamond ContributorWhich exactly case do you mean? The question was about converting text to datetime.
- Dezmaster2020Feb 26, 2021Copper Contributor
Yes. I followed your recommendations but I have some instances where I have negative values in my calculation.
You will find some examples in the columns highlighted in red (calculated) in my dataset