SOLVED

Time format

%3CLINGO-SUB%20id%3D%22lingo-sub-2107156%22%20slang%3D%22en-US%22%3ETime%20format%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2107156%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20looking%20at%20some%20data%20which%20produce%20by%20a%20computer%2C%20the%20time%20format%20is%20wrong.%20It's%20displayed%20like%20this%20below%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CTABLE%20width%3D%22257%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%22166%22%3E%5Bh%3Amin%3As%5D%3C%2FTD%3E%3CTD%20width%3D%2291%22%3E01%3A37%3A53%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E%5Bmin%3As%5D%3C%2FTD%3E%3CTD%3E09%3A24%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20minute%20section%20should%20read%2000%3A09%3A24.%20How%20can%20I%20covert%20this%20into%20the%20correct%20format%20without%20manually%20editing%20the%20cell%20every%20time%3F%20I%20plan%20to%20use%20a%20macro%20to%20do%20this%20if%20I%20can%20get%20the%20format%20correct.%20I'm%20trying%20to%20work%20out%20the%20%25%20different%20between%20the%20two%20times.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2107156%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Regular Visitor

Hello, 

I'm looking at some data which produce by a computer, the time format is wrong. It's displayed like this below;

 

[h:min:s]01:37:53
[min:s]09:24

 

The minute section should read 00:09:24. How can I covert this into the correct format without manually editing the cell every time? I plan to use a macro to do this if I can get the format correct. I'm trying to work out the % different between the two times. 

 

Thanks in advance. 

4 Replies

@dan3460 

It's better to have sample file. Since right column is left aligned most probably you have texts, not times in term of Excel (actually they are numbers, 00:09:24 is equal to (9+24/60)/24/60 or 0.00652777777777778).

How to convert to time - it depends on presentation logic, in particular formats on the left are parts of the grid or that's your interpretation.

After texts are converted to times I see no difference in which format time will be presented to calculate the difference.

best response confirmed by dan3460 (Regular Visitor)
Solution

@dan3460 

As you have already been recommended, it is always better to upload a file (without sensitive data)

and explain the problem in detail.

 

However, here is some information on how to do it, depending on your needs.

 

Format numbers as dates or times

https://support.microsoft.com/en-us/office/format-numbers-as-dates-or-times-418bd3fe-0577-47c8-8caa-...

 

Format function

https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/format-function-v...

 

I would be happy to know if I could help.

Nikolino

I know I don't know anything (Socrates)

 

* Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here.

@Nikolino 

Afraid that doesn't work in this case, to format number as date you need first to convert text to number.

@dan3460 

It works safely with VBA, here is an example of how and with which formats you could work.

I found this example file on the Internet.

A great job by Karin Mohnhaupt as far as I understood it on this

website: http://hajo-excel.de/vba_date.htm

 

You can set the VBA code as you wish.

 

Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here.

 

Wish you a nice day.

Nikolino

I know I don't know anything (Socrates)