Convert time string/text to time (calculable)How to get Excel 2003 to treat long string of numbers as...

At what level can a party fight a mimic?

Graphing random points on the XY-plane

How do you say "powers of ten"?

What type of investment is best suited for a 1-year investment on a down payment?

How can I create a Table like this in Latex?

Wrap all numerics in JSON with quotes

The need of reserving one's ability in job interviews

Six real numbers so that product of any five is the sixth one

Is the withholding of funding notice allowed?

Can throughput exceed the bandwidth of a network

Why can't we make a perpetual motion machine by using a magnet to pull up a piece of metal, then letting it fall back down?

How to make a *empty* field behaves like a *null* field when it comes to standard values?

Is knowledge about monster types inherent?

Is there any relevance to Thor getting his hair cut other than comedic value?

How can atoms be electrically neutral when there is a difference in the positions of the charges?

What is the difference between a forward slip and a side slip?

Achieving MPPT of a solar panel with LM2596

lead or lag function to get several values, not just the nth

How to lift/raise/repair a segment of concrete slab?

Book about a time-travel war fought by computers

I can't die. Who am I?

Why do phishing e-mails use faked e-mail addresses instead of the real one?

What is better: yes / no radio, or simple checkbox?

Should we avoid writing fiction about historical events without extensive research?



Convert time string/text to time (calculable)


How to get Excel 2003 to treat long string of numbers as text?Excel formula to get time difference as a decimal numberAverage using Elapsed Time processing a number of docsDATEVALUE() gives different values for similar dataConvert text/general format time into numeric value that can be filteredConvert time strings to Excel time formatExtract numbers from a string in ExcelMicrosoft Excel - merging cells with date and timeMultiple date formats in single column in excelHow to convert an equation string in Excel to actual equation?













1















I have a column of data which consists of strings such as follows:



Row 1: 46m 06s.



Row 2: 15d 5h 09m 33s



Row 3: 17h 24m 59s



Etc



I want to convert these strings to number or time format so I can perform calculations on them, but the current format makes various formula challenging to use. Ideas?










share|improve this question









New contributor




Rox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • These are all really good ideas. I’ll test them out, particularly non-code ones since I need to keep the file simple for those who inherit the file later on

    – Rox
    18 hours ago
















1















I have a column of data which consists of strings such as follows:



Row 1: 46m 06s.



Row 2: 15d 5h 09m 33s



Row 3: 17h 24m 59s



Etc



I want to convert these strings to number or time format so I can perform calculations on them, but the current format makes various formula challenging to use. Ideas?










share|improve this question









New contributor




Rox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • These are all really good ideas. I’ll test them out, particularly non-code ones since I need to keep the file simple for those who inherit the file later on

    – Rox
    18 hours ago














1












1








1








I have a column of data which consists of strings such as follows:



Row 1: 46m 06s.



Row 2: 15d 5h 09m 33s



Row 3: 17h 24m 59s



Etc



I want to convert these strings to number or time format so I can perform calculations on them, but the current format makes various formula challenging to use. Ideas?










share|improve this question









New contributor




Rox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I have a column of data which consists of strings such as follows:



Row 1: 46m 06s.



Row 2: 15d 5h 09m 33s



Row 3: 17h 24m 59s



Etc



I want to convert these strings to number or time format so I can perform calculations on them, but the current format makes various formula challenging to use. Ideas?







microsoft-excel worksheet-function microsoft-excel-2010 microsoft-excel-2016






share|improve this question









New contributor




Rox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Rox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 5 hours ago







Rox













New contributor




Rox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 23 hours ago









RoxRox

62




62




New contributor




Rox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Rox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Rox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • These are all really good ideas. I’ll test them out, particularly non-code ones since I need to keep the file simple for those who inherit the file later on

    – Rox
    18 hours ago



















  • These are all really good ideas. I’ll test them out, particularly non-code ones since I need to keep the file simple for those who inherit the file later on

    – Rox
    18 hours ago

















These are all really good ideas. I’ll test them out, particularly non-code ones since I need to keep the file simple for those who inherit the file later on

– Rox
18 hours ago





These are all really good ideas. I’ll test them out, particularly non-code ones since I need to keep the file simple for those who inherit the file later on

– Rox
18 hours ago










3 Answers
3






active

oldest

votes


















2














Public Function convert_text_to_interval(interval As String) As Double
Dim temp() As String, tmp As Variant
On Error GoTo error_handler
temp = Split(interval)
For Each tmp In temp
Select Case Right(Trim(tmp), 1)
Case "d"
convert_text_to_interval = convert_text_to_interval + Val(tmp)
Case "h"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 24#
Case "m"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 1440#
Case "s"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 86400#
End Select
Next
Exit Function

error_handler:
convert_text_to_interval = 0
End Function


The function must be inserted into a common module (not to a sheet or class module!).



After insertion it will be available in formula master in User-defined functions section. Or it can be inserted directly (for example, as =convert_text_to_interval(A1)).



usage



The spaces between interval parts are compulsory (1h30m not allowed, it will be treated as 1m, see below).



The unit letter must be adjacent to a value (1 h 30 m not allowed, it will be treated as 0h 0m, see below).



The parts without correct unit letter are ignored. If unit part contains more than 1 letter, the last one is used, all another are ignored (1hm == 1m). All non-digit symbols except the last unit letter are ignored.



Multiple parts with the same unit (1h 15m 30m == 1h 45m) are allowed.



Fractional values (decimal separator - dot .) are allowed (1.5h). Negative values are allowed (2h -20m == 1h 40m).



NumberFormat for a cell where this function is used can be both number and time (in last case recommended format is Cell.NumberFormat = "[h]:mm:ss" - it will not cut hours over a day, for example, 15d 5h 09m 33s will be shown as 365:09:33, not 5:09:33 as for "h:mm:ss" format).






share|improve this answer


























  • Include an example that how to use the Function for example =convert_text_text_to_interval(Cell refe).

    – Rajesh S
    22 hours ago













  • Your code needs this corrections,, tmp As Variant instead of String and Case code should Case "h" instead of Case 'h'. Also what about the Format of the Formula Cell !!

    – Rajesh S
    22 hours ago











  • Case code should Case "h" instead of Case 'h' Thanks, edited. tmp As Variant instead of String Edited too. what about the Format of the Formula Cell As user needed (maybe number, maybe time).

    – Akina
    22 hours ago











  • For this line ,,dim temp() as string, tmp it should dim temp() as string, tmp as Variant. And for the first example if Formula cell is Number the Ans is Zero,, if Time the is 12:07:00 AM ,, I think it should 01:46:06 AM instead.

    – Rajesh S
    22 hours ago













  • @RajeshS And for the first example if Formula cell is Number the Ans is Zero,, if Time the is 12:07:00 AM ,, I think it should 01:46:06 AM instead. I cannot understand this phrase. And why AM - it is interval, not time.

    – Akina
    21 hours ago





















1














Parses a String of text for 'd' 'h' 'm' 's' values and converts to time.



sample data output



This will not replace the string values. Instead, use this formula to create a helper column for the time arithmetic.




  • To enable the display of over 24 hours in in the time formula cells, use the [h]:mm:ss time format.

  • All value & letter pairs in the time string are optional. If the letter is present, the value must be attached.

  • No space between value and unit letter 3h not 3 h (not: 3 space h)

  • Separate one pair from the next with a space. 3d 2h (3d space 2h)

    This is an error: 3d2h (if it has two digits, like the 11 in 3d11h, it should be ok).

  • The letters are case insensitive (e.g. 'h' or 'H').


Multiline formatted formula: Paste directly into the formula bar

to avoid splitting the formula over multiple rows.



=VALUE( IFERROR( LEFT( I11, SEARCH( "d", I11) - 1),0) * 24 +
IFERROR( IFERROR( MID( I11, SEARCH( "h", I11) - 2, 2), MID( I11, SEARCH( "h", I11) - 1, 1)), 0) & ":" &
IFERROR( IFERROR( MID( I11, SEARCH( "m", I11) - 2, 2), MID( I11, SEARCH( "m", I11) - 1, 1)), 0) & ":" &
IFERROR( IFERROR( MID( I11, SEARCH( "s", I11) - 2, 2), MID( I11, SEARCH( "s", I11) - 1, 1)), 0))


The value I11 is the cell with the time string (search and replace).

- Or create (insert) helper column.

- Insert new row.

- Paste formula in new row in helper column.

- Cut cell I11 and paste in new row's time string column (assumes I11 is not referenced by an existing formula).

- Copy the contents of original I11 back to the formula bar of I11 so the relative addresses are not moved back, just the contents.






share|improve this answer


























  • It's working,, now you get 10 ☺

    – Rajesh S
    21 hours ago



















0














Your issue can be solved by using few Helper Columns also:



enter image description here



How it works:




  • Sample data in Range A4:E29.


  • D, H, M & S indicates Day, Hour, Minute &
    Second
    .


  • Formula in B4 & fill down:



    =VALUE(IFERROR(LEFT(A4,SEARCH("d",A4)-1),0)*24)/24




  • Formula in C4 & fill down:



    =IF(ISNUMBER(SEARCH(C$3,$A4)),MID($A4,IF(SEARCH(C$3,$A4)<5,1,SEARCH(C$3,$A4)-2),IF(SEARCH(C$3,$A4)<5,SEARCH(C$3,$A4)-1,2)),0)*1




  • Formula in D4 & fill down:



    =IF(ISNUMBER(SEARCH(D$3,$A4)),MID($A4,IF(SEARCH(D$3,$A4)<5,1,SEARCH(D$3,$A4)-2),IF(SEARCH(D$3,$A4)<5,SEARCH(D$3,$A4)-1,2)),0)*1




  • Formula in E4 & fill down:



    =IF(ISNUMBER(SEARCH(E$3,$A4)),MID($A4,IF(SEARCH(E$3,$A4)<5,1,SEARCH(E$3,$A4)-2),IF(SEARCH(E$3,$A4)<5,SEARCH(E$3,$A4)-1,2)),0)*1



  • Final Formula in F4:



=IF(LEN(A4)>1,B4+C4/24+D4/(24*60)+E4/(24*60^2),"")



N.B.




  • Cell Format for Range B4:E29 is GENERAL.

  • Cell Format for Range F4:F29 is [h]:mm:ss.






share|improve this answer
























  • These are all really good ideas. I’ll test them out, particularly non-code ones since I need to keep the file simple for those who inherit the file later on

    – Rox
    18 hours ago













  • @Rox,, glad to help you,, I've tried to include as many example I can,, follow instructions properly, you also find is working. ☺

    – Rajesh S
    18 hours ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Rox is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1411316%2fconvert-time-string-text-to-time-calculable%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Public Function convert_text_to_interval(interval As String) As Double
Dim temp() As String, tmp As Variant
On Error GoTo error_handler
temp = Split(interval)
For Each tmp In temp
Select Case Right(Trim(tmp), 1)
Case "d"
convert_text_to_interval = convert_text_to_interval + Val(tmp)
Case "h"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 24#
Case "m"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 1440#
Case "s"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 86400#
End Select
Next
Exit Function

error_handler:
convert_text_to_interval = 0
End Function


The function must be inserted into a common module (not to a sheet or class module!).



After insertion it will be available in formula master in User-defined functions section. Or it can be inserted directly (for example, as =convert_text_to_interval(A1)).



usage



The spaces between interval parts are compulsory (1h30m not allowed, it will be treated as 1m, see below).



The unit letter must be adjacent to a value (1 h 30 m not allowed, it will be treated as 0h 0m, see below).



The parts without correct unit letter are ignored. If unit part contains more than 1 letter, the last one is used, all another are ignored (1hm == 1m). All non-digit symbols except the last unit letter are ignored.



Multiple parts with the same unit (1h 15m 30m == 1h 45m) are allowed.



Fractional values (decimal separator - dot .) are allowed (1.5h). Negative values are allowed (2h -20m == 1h 40m).



NumberFormat for a cell where this function is used can be both number and time (in last case recommended format is Cell.NumberFormat = "[h]:mm:ss" - it will not cut hours over a day, for example, 15d 5h 09m 33s will be shown as 365:09:33, not 5:09:33 as for "h:mm:ss" format).






share|improve this answer


























  • Include an example that how to use the Function for example =convert_text_text_to_interval(Cell refe).

    – Rajesh S
    22 hours ago













  • Your code needs this corrections,, tmp As Variant instead of String and Case code should Case "h" instead of Case 'h'. Also what about the Format of the Formula Cell !!

    – Rajesh S
    22 hours ago











  • Case code should Case "h" instead of Case 'h' Thanks, edited. tmp As Variant instead of String Edited too. what about the Format of the Formula Cell As user needed (maybe number, maybe time).

    – Akina
    22 hours ago











  • For this line ,,dim temp() as string, tmp it should dim temp() as string, tmp as Variant. And for the first example if Formula cell is Number the Ans is Zero,, if Time the is 12:07:00 AM ,, I think it should 01:46:06 AM instead.

    – Rajesh S
    22 hours ago













  • @RajeshS And for the first example if Formula cell is Number the Ans is Zero,, if Time the is 12:07:00 AM ,, I think it should 01:46:06 AM instead. I cannot understand this phrase. And why AM - it is interval, not time.

    – Akina
    21 hours ago


















2














Public Function convert_text_to_interval(interval As String) As Double
Dim temp() As String, tmp As Variant
On Error GoTo error_handler
temp = Split(interval)
For Each tmp In temp
Select Case Right(Trim(tmp), 1)
Case "d"
convert_text_to_interval = convert_text_to_interval + Val(tmp)
Case "h"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 24#
Case "m"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 1440#
Case "s"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 86400#
End Select
Next
Exit Function

error_handler:
convert_text_to_interval = 0
End Function


The function must be inserted into a common module (not to a sheet or class module!).



After insertion it will be available in formula master in User-defined functions section. Or it can be inserted directly (for example, as =convert_text_to_interval(A1)).



usage



The spaces between interval parts are compulsory (1h30m not allowed, it will be treated as 1m, see below).



The unit letter must be adjacent to a value (1 h 30 m not allowed, it will be treated as 0h 0m, see below).



The parts without correct unit letter are ignored. If unit part contains more than 1 letter, the last one is used, all another are ignored (1hm == 1m). All non-digit symbols except the last unit letter are ignored.



Multiple parts with the same unit (1h 15m 30m == 1h 45m) are allowed.



Fractional values (decimal separator - dot .) are allowed (1.5h). Negative values are allowed (2h -20m == 1h 40m).



NumberFormat for a cell where this function is used can be both number and time (in last case recommended format is Cell.NumberFormat = "[h]:mm:ss" - it will not cut hours over a day, for example, 15d 5h 09m 33s will be shown as 365:09:33, not 5:09:33 as for "h:mm:ss" format).






share|improve this answer


























  • Include an example that how to use the Function for example =convert_text_text_to_interval(Cell refe).

    – Rajesh S
    22 hours ago













  • Your code needs this corrections,, tmp As Variant instead of String and Case code should Case "h" instead of Case 'h'. Also what about the Format of the Formula Cell !!

    – Rajesh S
    22 hours ago











  • Case code should Case "h" instead of Case 'h' Thanks, edited. tmp As Variant instead of String Edited too. what about the Format of the Formula Cell As user needed (maybe number, maybe time).

    – Akina
    22 hours ago











  • For this line ,,dim temp() as string, tmp it should dim temp() as string, tmp as Variant. And for the first example if Formula cell is Number the Ans is Zero,, if Time the is 12:07:00 AM ,, I think it should 01:46:06 AM instead.

    – Rajesh S
    22 hours ago













  • @RajeshS And for the first example if Formula cell is Number the Ans is Zero,, if Time the is 12:07:00 AM ,, I think it should 01:46:06 AM instead. I cannot understand this phrase. And why AM - it is interval, not time.

    – Akina
    21 hours ago
















2












2








2







Public Function convert_text_to_interval(interval As String) As Double
Dim temp() As String, tmp As Variant
On Error GoTo error_handler
temp = Split(interval)
For Each tmp In temp
Select Case Right(Trim(tmp), 1)
Case "d"
convert_text_to_interval = convert_text_to_interval + Val(tmp)
Case "h"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 24#
Case "m"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 1440#
Case "s"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 86400#
End Select
Next
Exit Function

error_handler:
convert_text_to_interval = 0
End Function


The function must be inserted into a common module (not to a sheet or class module!).



After insertion it will be available in formula master in User-defined functions section. Or it can be inserted directly (for example, as =convert_text_to_interval(A1)).



usage



The spaces between interval parts are compulsory (1h30m not allowed, it will be treated as 1m, see below).



The unit letter must be adjacent to a value (1 h 30 m not allowed, it will be treated as 0h 0m, see below).



The parts without correct unit letter are ignored. If unit part contains more than 1 letter, the last one is used, all another are ignored (1hm == 1m). All non-digit symbols except the last unit letter are ignored.



Multiple parts with the same unit (1h 15m 30m == 1h 45m) are allowed.



Fractional values (decimal separator - dot .) are allowed (1.5h). Negative values are allowed (2h -20m == 1h 40m).



NumberFormat for a cell where this function is used can be both number and time (in last case recommended format is Cell.NumberFormat = "[h]:mm:ss" - it will not cut hours over a day, for example, 15d 5h 09m 33s will be shown as 365:09:33, not 5:09:33 as for "h:mm:ss" format).






share|improve this answer















Public Function convert_text_to_interval(interval As String) As Double
Dim temp() As String, tmp As Variant
On Error GoTo error_handler
temp = Split(interval)
For Each tmp In temp
Select Case Right(Trim(tmp), 1)
Case "d"
convert_text_to_interval = convert_text_to_interval + Val(tmp)
Case "h"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 24#
Case "m"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 1440#
Case "s"
convert_text_to_interval = convert_text_to_interval + Val(tmp) / 86400#
End Select
Next
Exit Function

error_handler:
convert_text_to_interval = 0
End Function


The function must be inserted into a common module (not to a sheet or class module!).



After insertion it will be available in formula master in User-defined functions section. Or it can be inserted directly (for example, as =convert_text_to_interval(A1)).



usage



The spaces between interval parts are compulsory (1h30m not allowed, it will be treated as 1m, see below).



The unit letter must be adjacent to a value (1 h 30 m not allowed, it will be treated as 0h 0m, see below).



The parts without correct unit letter are ignored. If unit part contains more than 1 letter, the last one is used, all another are ignored (1hm == 1m). All non-digit symbols except the last unit letter are ignored.



Multiple parts with the same unit (1h 15m 30m == 1h 45m) are allowed.



Fractional values (decimal separator - dot .) are allowed (1.5h). Negative values are allowed (2h -20m == 1h 40m).



NumberFormat for a cell where this function is used can be both number and time (in last case recommended format is Cell.NumberFormat = "[h]:mm:ss" - it will not cut hours over a day, for example, 15d 5h 09m 33s will be shown as 365:09:33, not 5:09:33 as for "h:mm:ss" format).







share|improve this answer














share|improve this answer



share|improve this answer








edited 21 hours ago

























answered 23 hours ago









AkinaAkina

1,35928




1,35928













  • Include an example that how to use the Function for example =convert_text_text_to_interval(Cell refe).

    – Rajesh S
    22 hours ago













  • Your code needs this corrections,, tmp As Variant instead of String and Case code should Case "h" instead of Case 'h'. Also what about the Format of the Formula Cell !!

    – Rajesh S
    22 hours ago











  • Case code should Case "h" instead of Case 'h' Thanks, edited. tmp As Variant instead of String Edited too. what about the Format of the Formula Cell As user needed (maybe number, maybe time).

    – Akina
    22 hours ago











  • For this line ,,dim temp() as string, tmp it should dim temp() as string, tmp as Variant. And for the first example if Formula cell is Number the Ans is Zero,, if Time the is 12:07:00 AM ,, I think it should 01:46:06 AM instead.

    – Rajesh S
    22 hours ago













  • @RajeshS And for the first example if Formula cell is Number the Ans is Zero,, if Time the is 12:07:00 AM ,, I think it should 01:46:06 AM instead. I cannot understand this phrase. And why AM - it is interval, not time.

    – Akina
    21 hours ago





















  • Include an example that how to use the Function for example =convert_text_text_to_interval(Cell refe).

    – Rajesh S
    22 hours ago













  • Your code needs this corrections,, tmp As Variant instead of String and Case code should Case "h" instead of Case 'h'. Also what about the Format of the Formula Cell !!

    – Rajesh S
    22 hours ago











  • Case code should Case "h" instead of Case 'h' Thanks, edited. tmp As Variant instead of String Edited too. what about the Format of the Formula Cell As user needed (maybe number, maybe time).

    – Akina
    22 hours ago











  • For this line ,,dim temp() as string, tmp it should dim temp() as string, tmp as Variant. And for the first example if Formula cell is Number the Ans is Zero,, if Time the is 12:07:00 AM ,, I think it should 01:46:06 AM instead.

    – Rajesh S
    22 hours ago













  • @RajeshS And for the first example if Formula cell is Number the Ans is Zero,, if Time the is 12:07:00 AM ,, I think it should 01:46:06 AM instead. I cannot understand this phrase. And why AM - it is interval, not time.

    – Akina
    21 hours ago



















Include an example that how to use the Function for example =convert_text_text_to_interval(Cell refe).

– Rajesh S
22 hours ago







Include an example that how to use the Function for example =convert_text_text_to_interval(Cell refe).

– Rajesh S
22 hours ago















Your code needs this corrections,, tmp As Variant instead of String and Case code should Case "h" instead of Case 'h'. Also what about the Format of the Formula Cell !!

– Rajesh S
22 hours ago





Your code needs this corrections,, tmp As Variant instead of String and Case code should Case "h" instead of Case 'h'. Also what about the Format of the Formula Cell !!

– Rajesh S
22 hours ago













Case code should Case "h" instead of Case 'h' Thanks, edited. tmp As Variant instead of String Edited too. what about the Format of the Formula Cell As user needed (maybe number, maybe time).

– Akina
22 hours ago





Case code should Case "h" instead of Case 'h' Thanks, edited. tmp As Variant instead of String Edited too. what about the Format of the Formula Cell As user needed (maybe number, maybe time).

– Akina
22 hours ago













For this line ,,dim temp() as string, tmp it should dim temp() as string, tmp as Variant. And for the first example if Formula cell is Number the Ans is Zero,, if Time the is 12:07:00 AM ,, I think it should 01:46:06 AM instead.

– Rajesh S
22 hours ago







For this line ,,dim temp() as string, tmp it should dim temp() as string, tmp as Variant. And for the first example if Formula cell is Number the Ans is Zero,, if Time the is 12:07:00 AM ,, I think it should 01:46:06 AM instead.

– Rajesh S
22 hours ago















@RajeshS And for the first example if Formula cell is Number the Ans is Zero,, if Time the is 12:07:00 AM ,, I think it should 01:46:06 AM instead. I cannot understand this phrase. And why AM - it is interval, not time.

– Akina
21 hours ago







@RajeshS And for the first example if Formula cell is Number the Ans is Zero,, if Time the is 12:07:00 AM ,, I think it should 01:46:06 AM instead. I cannot understand this phrase. And why AM - it is interval, not time.

– Akina
21 hours ago















1














Parses a String of text for 'd' 'h' 'm' 's' values and converts to time.



sample data output



This will not replace the string values. Instead, use this formula to create a helper column for the time arithmetic.




  • To enable the display of over 24 hours in in the time formula cells, use the [h]:mm:ss time format.

  • All value & letter pairs in the time string are optional. If the letter is present, the value must be attached.

  • No space between value and unit letter 3h not 3 h (not: 3 space h)

  • Separate one pair from the next with a space. 3d 2h (3d space 2h)

    This is an error: 3d2h (if it has two digits, like the 11 in 3d11h, it should be ok).

  • The letters are case insensitive (e.g. 'h' or 'H').


Multiline formatted formula: Paste directly into the formula bar

to avoid splitting the formula over multiple rows.



=VALUE( IFERROR( LEFT( I11, SEARCH( "d", I11) - 1),0) * 24 +
IFERROR( IFERROR( MID( I11, SEARCH( "h", I11) - 2, 2), MID( I11, SEARCH( "h", I11) - 1, 1)), 0) & ":" &
IFERROR( IFERROR( MID( I11, SEARCH( "m", I11) - 2, 2), MID( I11, SEARCH( "m", I11) - 1, 1)), 0) & ":" &
IFERROR( IFERROR( MID( I11, SEARCH( "s", I11) - 2, 2), MID( I11, SEARCH( "s", I11) - 1, 1)), 0))


The value I11 is the cell with the time string (search and replace).

- Or create (insert) helper column.

- Insert new row.

- Paste formula in new row in helper column.

- Cut cell I11 and paste in new row's time string column (assumes I11 is not referenced by an existing formula).

- Copy the contents of original I11 back to the formula bar of I11 so the relative addresses are not moved back, just the contents.






share|improve this answer


























  • It's working,, now you get 10 ☺

    – Rajesh S
    21 hours ago
















1














Parses a String of text for 'd' 'h' 'm' 's' values and converts to time.



sample data output



This will not replace the string values. Instead, use this formula to create a helper column for the time arithmetic.




  • To enable the display of over 24 hours in in the time formula cells, use the [h]:mm:ss time format.

  • All value & letter pairs in the time string are optional. If the letter is present, the value must be attached.

  • No space between value and unit letter 3h not 3 h (not: 3 space h)

  • Separate one pair from the next with a space. 3d 2h (3d space 2h)

    This is an error: 3d2h (if it has two digits, like the 11 in 3d11h, it should be ok).

  • The letters are case insensitive (e.g. 'h' or 'H').


Multiline formatted formula: Paste directly into the formula bar

to avoid splitting the formula over multiple rows.



=VALUE( IFERROR( LEFT( I11, SEARCH( "d", I11) - 1),0) * 24 +
IFERROR( IFERROR( MID( I11, SEARCH( "h", I11) - 2, 2), MID( I11, SEARCH( "h", I11) - 1, 1)), 0) & ":" &
IFERROR( IFERROR( MID( I11, SEARCH( "m", I11) - 2, 2), MID( I11, SEARCH( "m", I11) - 1, 1)), 0) & ":" &
IFERROR( IFERROR( MID( I11, SEARCH( "s", I11) - 2, 2), MID( I11, SEARCH( "s", I11) - 1, 1)), 0))


The value I11 is the cell with the time string (search and replace).

- Or create (insert) helper column.

- Insert new row.

- Paste formula in new row in helper column.

- Cut cell I11 and paste in new row's time string column (assumes I11 is not referenced by an existing formula).

- Copy the contents of original I11 back to the formula bar of I11 so the relative addresses are not moved back, just the contents.






share|improve this answer


























  • It's working,, now you get 10 ☺

    – Rajesh S
    21 hours ago














1












1








1







Parses a String of text for 'd' 'h' 'm' 's' values and converts to time.



sample data output



This will not replace the string values. Instead, use this formula to create a helper column for the time arithmetic.




  • To enable the display of over 24 hours in in the time formula cells, use the [h]:mm:ss time format.

  • All value & letter pairs in the time string are optional. If the letter is present, the value must be attached.

  • No space between value and unit letter 3h not 3 h (not: 3 space h)

  • Separate one pair from the next with a space. 3d 2h (3d space 2h)

    This is an error: 3d2h (if it has two digits, like the 11 in 3d11h, it should be ok).

  • The letters are case insensitive (e.g. 'h' or 'H').


Multiline formatted formula: Paste directly into the formula bar

to avoid splitting the formula over multiple rows.



=VALUE( IFERROR( LEFT( I11, SEARCH( "d", I11) - 1),0) * 24 +
IFERROR( IFERROR( MID( I11, SEARCH( "h", I11) - 2, 2), MID( I11, SEARCH( "h", I11) - 1, 1)), 0) & ":" &
IFERROR( IFERROR( MID( I11, SEARCH( "m", I11) - 2, 2), MID( I11, SEARCH( "m", I11) - 1, 1)), 0) & ":" &
IFERROR( IFERROR( MID( I11, SEARCH( "s", I11) - 2, 2), MID( I11, SEARCH( "s", I11) - 1, 1)), 0))


The value I11 is the cell with the time string (search and replace).

- Or create (insert) helper column.

- Insert new row.

- Paste formula in new row in helper column.

- Cut cell I11 and paste in new row's time string column (assumes I11 is not referenced by an existing formula).

- Copy the contents of original I11 back to the formula bar of I11 so the relative addresses are not moved back, just the contents.






share|improve this answer















Parses a String of text for 'd' 'h' 'm' 's' values and converts to time.



sample data output



This will not replace the string values. Instead, use this formula to create a helper column for the time arithmetic.




  • To enable the display of over 24 hours in in the time formula cells, use the [h]:mm:ss time format.

  • All value & letter pairs in the time string are optional. If the letter is present, the value must be attached.

  • No space between value and unit letter 3h not 3 h (not: 3 space h)

  • Separate one pair from the next with a space. 3d 2h (3d space 2h)

    This is an error: 3d2h (if it has two digits, like the 11 in 3d11h, it should be ok).

  • The letters are case insensitive (e.g. 'h' or 'H').


Multiline formatted formula: Paste directly into the formula bar

to avoid splitting the formula over multiple rows.



=VALUE( IFERROR( LEFT( I11, SEARCH( "d", I11) - 1),0) * 24 +
IFERROR( IFERROR( MID( I11, SEARCH( "h", I11) - 2, 2), MID( I11, SEARCH( "h", I11) - 1, 1)), 0) & ":" &
IFERROR( IFERROR( MID( I11, SEARCH( "m", I11) - 2, 2), MID( I11, SEARCH( "m", I11) - 1, 1)), 0) & ":" &
IFERROR( IFERROR( MID( I11, SEARCH( "s", I11) - 2, 2), MID( I11, SEARCH( "s", I11) - 1, 1)), 0))


The value I11 is the cell with the time string (search and replace).

- Or create (insert) helper column.

- Insert new row.

- Paste formula in new row in helper column.

- Cut cell I11 and paste in new row's time string column (assumes I11 is not referenced by an existing formula).

- Copy the contents of original I11 back to the formula bar of I11 so the relative addresses are not moved back, just the contents.







share|improve this answer














share|improve this answer



share|improve this answer








edited 13 hours ago

























answered 21 hours ago









Ted D.Ted D.

4968




4968













  • It's working,, now you get 10 ☺

    – Rajesh S
    21 hours ago



















  • It's working,, now you get 10 ☺

    – Rajesh S
    21 hours ago

















It's working,, now you get 10 ☺

– Rajesh S
21 hours ago





It's working,, now you get 10 ☺

– Rajesh S
21 hours ago











0














Your issue can be solved by using few Helper Columns also:



enter image description here



How it works:




  • Sample data in Range A4:E29.


  • D, H, M & S indicates Day, Hour, Minute &
    Second
    .


  • Formula in B4 & fill down:



    =VALUE(IFERROR(LEFT(A4,SEARCH("d",A4)-1),0)*24)/24




  • Formula in C4 & fill down:



    =IF(ISNUMBER(SEARCH(C$3,$A4)),MID($A4,IF(SEARCH(C$3,$A4)<5,1,SEARCH(C$3,$A4)-2),IF(SEARCH(C$3,$A4)<5,SEARCH(C$3,$A4)-1,2)),0)*1




  • Formula in D4 & fill down:



    =IF(ISNUMBER(SEARCH(D$3,$A4)),MID($A4,IF(SEARCH(D$3,$A4)<5,1,SEARCH(D$3,$A4)-2),IF(SEARCH(D$3,$A4)<5,SEARCH(D$3,$A4)-1,2)),0)*1




  • Formula in E4 & fill down:



    =IF(ISNUMBER(SEARCH(E$3,$A4)),MID($A4,IF(SEARCH(E$3,$A4)<5,1,SEARCH(E$3,$A4)-2),IF(SEARCH(E$3,$A4)<5,SEARCH(E$3,$A4)-1,2)),0)*1



  • Final Formula in F4:



=IF(LEN(A4)>1,B4+C4/24+D4/(24*60)+E4/(24*60^2),"")



N.B.




  • Cell Format for Range B4:E29 is GENERAL.

  • Cell Format for Range F4:F29 is [h]:mm:ss.






share|improve this answer
























  • These are all really good ideas. I’ll test them out, particularly non-code ones since I need to keep the file simple for those who inherit the file later on

    – Rox
    18 hours ago













  • @Rox,, glad to help you,, I've tried to include as many example I can,, follow instructions properly, you also find is working. ☺

    – Rajesh S
    18 hours ago
















0














Your issue can be solved by using few Helper Columns also:



enter image description here



How it works:




  • Sample data in Range A4:E29.


  • D, H, M & S indicates Day, Hour, Minute &
    Second
    .


  • Formula in B4 & fill down:



    =VALUE(IFERROR(LEFT(A4,SEARCH("d",A4)-1),0)*24)/24




  • Formula in C4 & fill down:



    =IF(ISNUMBER(SEARCH(C$3,$A4)),MID($A4,IF(SEARCH(C$3,$A4)<5,1,SEARCH(C$3,$A4)-2),IF(SEARCH(C$3,$A4)<5,SEARCH(C$3,$A4)-1,2)),0)*1




  • Formula in D4 & fill down:



    =IF(ISNUMBER(SEARCH(D$3,$A4)),MID($A4,IF(SEARCH(D$3,$A4)<5,1,SEARCH(D$3,$A4)-2),IF(SEARCH(D$3,$A4)<5,SEARCH(D$3,$A4)-1,2)),0)*1




  • Formula in E4 & fill down:



    =IF(ISNUMBER(SEARCH(E$3,$A4)),MID($A4,IF(SEARCH(E$3,$A4)<5,1,SEARCH(E$3,$A4)-2),IF(SEARCH(E$3,$A4)<5,SEARCH(E$3,$A4)-1,2)),0)*1



  • Final Formula in F4:



=IF(LEN(A4)>1,B4+C4/24+D4/(24*60)+E4/(24*60^2),"")



N.B.




  • Cell Format for Range B4:E29 is GENERAL.

  • Cell Format for Range F4:F29 is [h]:mm:ss.






share|improve this answer
























  • These are all really good ideas. I’ll test them out, particularly non-code ones since I need to keep the file simple for those who inherit the file later on

    – Rox
    18 hours ago













  • @Rox,, glad to help you,, I've tried to include as many example I can,, follow instructions properly, you also find is working. ☺

    – Rajesh S
    18 hours ago














0












0








0







Your issue can be solved by using few Helper Columns also:



enter image description here



How it works:




  • Sample data in Range A4:E29.


  • D, H, M & S indicates Day, Hour, Minute &
    Second
    .


  • Formula in B4 & fill down:



    =VALUE(IFERROR(LEFT(A4,SEARCH("d",A4)-1),0)*24)/24




  • Formula in C4 & fill down:



    =IF(ISNUMBER(SEARCH(C$3,$A4)),MID($A4,IF(SEARCH(C$3,$A4)<5,1,SEARCH(C$3,$A4)-2),IF(SEARCH(C$3,$A4)<5,SEARCH(C$3,$A4)-1,2)),0)*1




  • Formula in D4 & fill down:



    =IF(ISNUMBER(SEARCH(D$3,$A4)),MID($A4,IF(SEARCH(D$3,$A4)<5,1,SEARCH(D$3,$A4)-2),IF(SEARCH(D$3,$A4)<5,SEARCH(D$3,$A4)-1,2)),0)*1




  • Formula in E4 & fill down:



    =IF(ISNUMBER(SEARCH(E$3,$A4)),MID($A4,IF(SEARCH(E$3,$A4)<5,1,SEARCH(E$3,$A4)-2),IF(SEARCH(E$3,$A4)<5,SEARCH(E$3,$A4)-1,2)),0)*1



  • Final Formula in F4:



=IF(LEN(A4)>1,B4+C4/24+D4/(24*60)+E4/(24*60^2),"")



N.B.




  • Cell Format for Range B4:E29 is GENERAL.

  • Cell Format for Range F4:F29 is [h]:mm:ss.






share|improve this answer













Your issue can be solved by using few Helper Columns also:



enter image description here



How it works:




  • Sample data in Range A4:E29.


  • D, H, M & S indicates Day, Hour, Minute &
    Second
    .


  • Formula in B4 & fill down:



    =VALUE(IFERROR(LEFT(A4,SEARCH("d",A4)-1),0)*24)/24




  • Formula in C4 & fill down:



    =IF(ISNUMBER(SEARCH(C$3,$A4)),MID($A4,IF(SEARCH(C$3,$A4)<5,1,SEARCH(C$3,$A4)-2),IF(SEARCH(C$3,$A4)<5,SEARCH(C$3,$A4)-1,2)),0)*1




  • Formula in D4 & fill down:



    =IF(ISNUMBER(SEARCH(D$3,$A4)),MID($A4,IF(SEARCH(D$3,$A4)<5,1,SEARCH(D$3,$A4)-2),IF(SEARCH(D$3,$A4)<5,SEARCH(D$3,$A4)-1,2)),0)*1




  • Formula in E4 & fill down:



    =IF(ISNUMBER(SEARCH(E$3,$A4)),MID($A4,IF(SEARCH(E$3,$A4)<5,1,SEARCH(E$3,$A4)-2),IF(SEARCH(E$3,$A4)<5,SEARCH(E$3,$A4)-1,2)),0)*1



  • Final Formula in F4:



=IF(LEN(A4)>1,B4+C4/24+D4/(24*60)+E4/(24*60^2),"")



N.B.




  • Cell Format for Range B4:E29 is GENERAL.

  • Cell Format for Range F4:F29 is [h]:mm:ss.







share|improve this answer












share|improve this answer



share|improve this answer










answered 19 hours ago









Rajesh SRajesh S

3,9941523




3,9941523













  • These are all really good ideas. I’ll test them out, particularly non-code ones since I need to keep the file simple for those who inherit the file later on

    – Rox
    18 hours ago













  • @Rox,, glad to help you,, I've tried to include as many example I can,, follow instructions properly, you also find is working. ☺

    – Rajesh S
    18 hours ago



















  • These are all really good ideas. I’ll test them out, particularly non-code ones since I need to keep the file simple for those who inherit the file later on

    – Rox
    18 hours ago













  • @Rox,, glad to help you,, I've tried to include as many example I can,, follow instructions properly, you also find is working. ☺

    – Rajesh S
    18 hours ago

















These are all really good ideas. I’ll test them out, particularly non-code ones since I need to keep the file simple for those who inherit the file later on

– Rox
18 hours ago







These are all really good ideas. I’ll test them out, particularly non-code ones since I need to keep the file simple for those who inherit the file later on

– Rox
18 hours ago















@Rox,, glad to help you,, I've tried to include as many example I can,, follow instructions properly, you also find is working. ☺

– Rajesh S
18 hours ago





@Rox,, glad to help you,, I've tried to include as many example I can,, follow instructions properly, you also find is working. ☺

– Rajesh S
18 hours ago










Rox is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Rox is a new contributor. Be nice, and check out our Code of Conduct.













Rox is a new contributor. Be nice, and check out our Code of Conduct.












Rox is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1411316%2fconvert-time-string-text-to-time-calculable%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

Tribunal Administrativo e Fiscal de Mirandela Referências Menu de...

looking for continuous Screen Capture for retroactivly reproducing errors, timeback machineRolling desktop...