exceldatetimesplittimestamp

Unable to extract timestamp from Date/Timestamp combo column in Excel 2016


I'm trying to extract a timestamp from a date/timestamp data combo into a different column, but I'm getting random numbers. I've tried text-to-columns, LEFT, and RIGHT. Then, I special-pasted the values thinking formatting might be messing with me. Nope. The values are still coming back wrong. For text-to-columns, I've delineated it with a space (ex: 2024-04-16 01:19:20) the original column maintains the date and then zeroes out the timestamp (00:00:00) instead of deleting it while the accurate timestamp is put into the new column. For LEFT and RIGHT functions, seemingly random numbers pop up when I try to isolate the string I want to transfer over. Even when I do the LEN and FIND functions, the length of characters is verifiably off and the FIND function returns an inaccurate position. The only thing I could think of is that the entered date is formatted slightly differently than what's shown on the spreadsheet, but a special paste didn't resolve the issue.


Solution

  • The reason functions like LEFT, RIGHT, LEN, and FIND are unreliable here is that Excel treats dates and timestamps as serial numbers under the hood. Excel stores dates and times as numeric values, where the integer portion represents the date and the decimal represents the time. When you try to use string-based functions like LEFT and RIGHT, Excel doesn’t interpret the date/timestamp as text but as a number, which is why you see random-looking (but not at all random as such) results. It is explained in detail on this page. For example:

    enter image description here

    To reliably extract parts of a date/timestamp, use Excel’s date and time functions (e.g., YEAR, MONTH, DAY, HOUR, MINUTE, SECOND). These functions work on the numeric serial format of the date and are designed to interpret it correctly, extracting each component accurately. For example:

    =HOUR(A1) will give the hour from a timestamp in cell A1. =MINUTE(A1) and =SECOND(A1) will give you the minute and second, respectively.

    If you need the timestamp portion (e.g., 01:19:20) as a text string, format it as =TEXT(A1,"hh:mm:ss"). This approach uses Excel’s date system to interpret the values correctly, avoiding the issues you faced with string manipulation functions.