Tips on data pre-processing: how to convert Text-type time data into Datetime-type data in Excel?

Have you ever experienced a problem that R failed in recognizing part of your time series data, and analysed them by omitting thousands of rows in your spreadsheet?

You then looked for the cause, and found that the time format of your data seemed to have subtle inconsistency in Excel. Some parts of the time data were Text-type (e.g., from row 335 to 344 in Fig. 1), while the other parts were Datetime-type (e.g., from row 324 to 334 in Fig. 1), though these data were downloaded from the same data logger at the same time.

Fig. 1 A screenshot of my data, illustrating the inconsistency time format problem.

So you tried to make the time format consistent, by selecting the whole column (e.g., Column A in Fig. 1), right-clicking, entering the Format Cells box, and choosing the desired format (e.g, in my case, I chose custom format, mm/dd/yyyy h:mm).

However, you found that this didn’t work on your Text-type data. So you tried again, and unfortunately, failed again. You even tried different types of paste and copy, but had no effect. After tens of failures, you gave up and decided to manually re-type time data row by row into the spreadsheet to amend the format, but “millions” of Text-type data which embellished in your good Datetime-type data here and there drove you crazy. You started to worry that you would be stuck in typing data for the rest of your life.

What’s worse, the Datetime-type data were also problematic, because Excel recognized months as days, (e.g., in Row 334 in Fig. 1, 12 is actually the day). You could also not be able to correct them by just changing the format setting. What a pissed-off moment!

Fig. 2 Only Rage Face can express my "rage" on Excel. Hahahaha....

But don’t be frustrated! I had fought with this moment many times, and eventually defeated it. Now, I’d love to share my tips with you on how to deal with this problem.

Why did this problem happened?

I have searched for the cause for a long time, and found that people who claimed the similar problems are most in Canada. So I speculated that the problem came from system regional setting. Later, I found other peoples’ explanations on the causation, which confirmed my speculation.

According to their explanations, if you imported US format (mm/dd/yyyy) time series data from your data logger into your computer which set as Canadian English/French format (dd/mm/yyyy), then Excel would mistake days as months when the days are under 12, while leave the rest (the days are greater than 12) as unrecognized, text-type data.

Here are two discussions I found on Stack overflow (http://stackoverflow.com/questions/4660906/some-dates-recognized-as-dates-some-dates-not-recognized-why)

Fig. 3 Other peoples' discussion on the same issue at Stack Overflow.

How to deal with this problem?

Firstly, check date settings in your computer.  

Click the time display at the right bottom of desktop to enter the Date and Time box, and click Change date and time…, entering Date and Time setting, and then click Change Calendar Setting, entering Region and Language box. Under Format tab, you can modify time format under Short date and Long date. In my case, I prefer MM/dd/yyyy to dd/MM/yyyy as the short date format in my computer.

This step helps you to avoid any further problem, if you need to import your data from external sources such as your data logger.

Fig. 4 Time format setting in the Window system.

Secondly, modify the wrong Datetime-type data.

(1) Change your wrong Datetime-type data into Text type data, by using TEXT Function. For example, the data in Column A, Row 329 is 12/08/2016 11:00:00 PM, with a custom format of mm/dd/yyyy. I use function: =TEXT(A329, “dd/mm/yyyy H:MM”) to convert it into Text-type data. Please note that I use format “dd/mm/yyyy” instead of “mm/dd/yyyy”, in order to exchange “months” with “days”.

Fig. 5 My illustration on how to convert Datetime-type data into Text-type data.

(2) Convert Text-type data into Date-type and Time-type data,by using DATE Function and TIME function. I used =DATE(MID(D329,7,4), LEFT(D329,2), MID(D329,4,2)) and =TIME(MID(D329,12,2),MID(A337,14,2),0) in Cell (E, 329) and Cell (F, 329) separately. Please note that in my case, I don’t need seconds, so I put 0 in the time function. Then I gathered Date and Time together at Cell (G, 329) by simple addition: E329+F329. You can also complete those steps at one time by putting DATE and TIME functions together in one cell. 

Fig. 6 My illustration on how to convert Text-type data into Datetime-type data.

Here is a detailed introduction on TEXT, DATE and TIME Functions:

                    Format                                                 Example

TEXT (Cell, “desired format”)   ==> TEXT(A329, “dd/mm/yyyy H:MM”)

DATE (year, month, day)           ==> DATE(MID(D329,7,4), LEFT(D329,2),MID(D329,4,2))

TIME (hour, minute, second)    ==> TIME(MID(D329,12,2),MID(A337,14,2),0)

In addition, here are the how the extract functions like MID and LEFT work:

MID (Cell, The location of first character to extract, the number of extracted characters)

MID Function extracts characters from inside of the string. For example, MID(D329,7,4) is equal to “2016”, because the “2” of “2016” in Cell D329 is the 7th characters, and 2016 consist of four characters.

LEFT (Cell, the number of extracted characters)

LEFT Function extracts characters starting from the left of the string. For example, LEFT(D329, 2) is equal to “08”, because “08” are first two characters at the left.

Please note that space or symbols like “/”, “:” or one space “”, are counted as one character.

Thirdly, convert other Text-type data into Datetime-type data by using the same functions introduced above.

You may encounter a new problem when your Text-type data contains “am” or “pm”. Unfortunately, I didn’t find a function to extract “am” or “pm” into 24-hour system. But you can use subtraction to overcome this problem.

For instance, Cell D337 is “08/13/16 12:10:18 AM”. If I use TIME(MID(A337,10,2),MID(A337,13,2),MID(A337,16,2)), then Excel gives me the result as “12:10:18” in the 24-hour system, which is “12:10:18 pm”.

Fig. 7 Illustration on how to deal with "am" or "pm" in your data.

So instead, I used TIME(MID(A337,10,2) -12,MID(A337,13,2),MID(A337,16,2)), and Excel gave me the exact result that I want, the “00:10:18”.

Fig. 8 Illustration on correct your time data by simple subtraction.

With above three steps, you can successfully arrange your “naughty” time series data in the “stupid” Excel. Life turns beautiful again!

If you have know more convenient ways to deal with this problem, please tell me by leaving your comments here. 🙂

Thank you for reading it!

April, 28, 2017

36 thoughts on “Tips on data pre-processing: how to convert Text-type time data into Datetime-type data in Excel?”

  1. As I am looking at your writing, I regret being unable to do outdoor activities due to Corona 19, and I miss my old daily life. If you also miss the daily life of those days, would you please visit my site once? My site is a site where I post about photos and daily life when I was free.keo nha cai

  2. Interesting to learn the habitat skirt was a direct result of DFO’s ‘no net loss’ policy—cool to see how regulations shaped a real-world fix for the 140 m² of marine habitat impacted. Makes me wonder how often solutions like this come up in other coastal cities. Either way, I’ll probably overthink shoreline projects next time I’m killing time.

  3. It turns out that when the date is less than 12, it gets mistaken for the month. No wonder it never matched! How do you guys handle this kind of situation? I’ve been hooked on this little site lately; it’s a great way to switch gears and get some inspiration.

  4. Nevertheless, this is the first text-based life simulator that genuinely integrates and replicates adult behavior. Compose your own narrative in this simulation game that is based on your choices. bitlife

  5. That moment when Excel turns part of your time data into text and completely misreads dates is such a nightmare—especially when 12 gets interpreted as the month instead of the day. I never thought the fix would lie in changing system regional settings, but it makes total sense now. Thanks for the clear explanation, and here’s a fun distraction while sorting through all that: play a quick game to give your brain a break.

  6. Because it functions well and receives regular upgrades, the delta iOS executor has grown to be one of the most popular tools in the Roblox community. delta ios

  7. WoodnZen is a premium handcrafted wooden goods brand and global exporter specializing in solid wood furniture, kitchenware, and home decor. We offer toxin-free, chemical-free wooden products like Wooden platters, crafted by skilled artisans using responsibly sourced wood. Focused on sustainability, quality, and customization, we exclusively cater to bulk orders worldwide.

  8. Great tips on handling Excel time data inconsistencies! Your Rocket Goal approach to solving text/datetime conversion issues is exactly what researchers need when working with time series data.
    click

  9. Really helpful guide for handling messy datetime formats in Excel. I’ve seen similar optimization discussions in gaming communities while testing tools like Delta 2.725 where proper data handling also improves overall performance.

  10. Could the regional-setting check be the first thing to verify when only part of a data-logger export is recognized as dates? I recently had a Markdown document where a small formatting mismatch became obvious only in live preview, so your TEXT/DATE/TIME workflow makes a strong case for validating the source before exporting. I would still test a dd/mm/yyyy sample, since the same conversion can invert a date that was already parsed correctly.

  11. This is a great point about handling messy data types before analysis. I often run into similar issues with 3D model files, where format mismatches cause headaches. For that, an obj to stl conversion tool has saved me time, though I’m curious if others have a preferred workflow for batch processing.

  12. This is a clever workaround for time-data cleaning, though Excel’s text-to-columns usually saves me the hassle. For anyone automating repetitive video edits instead, a faceless video tool might save similar headaches with caption timing. Thanks for sharing the step-by-step logic behind the datetime conversion.

  13. I’ve encountered the exact same issue with data loggers and Excel’s inconsistent time formats. Your description of the frustration is spot on, especially when the ‘Format Cells’ option fails on text-type data. I found that using Excel’s ‘Text to Columns’ feature with a delimiter and then selecting ‘Date’ as the column format often helps, but it still requires careful attention to the order of month and day. Another tip is to use the DATEVALUE and TIMEVALUE functions in a helper column to parse the text and then combine them. However, as you mentioned, even after converting, the day/month misinterpretation remains a tricky problem. Have you tried using the ‘Data > From Text/CSV’ import method with a custom date format? That has worked for me sometimes. Thanks for sharing your insights and the humorous rage face—it perfectly captures the pain!

  14. Seeing 12/08/2016 interpreted differently from the intended month/day order makes the regional-setting check essential. I would test a small sample with DATE/TIME, compare it with the logger source, and only then convert the full column.

  15. Oh, I’ve definitely hit that wall where Excel thinks 12 is the month instead of the day—row 334 sounds painfully familiar. Did you end up writing a script to batch convert the text cells, or is there a simpler workaround you’d recommend for someone dealing with this? I’ve been trying to figure out a clean fix myself, and found this resource pretty helpful for similar data cleanup headaches.

  16. Understanding how piso wifi works can help users manage their internet sessions more easily. A clear guide explaining connection steps, browsing access, and common issues makes the process simpler for beginners.

Leave a Reply

Your email address will not be published. Required fields are marked *