Skip to content

Instantly share code, notes, and snippets.

@maravedi
Created January 17, 2019 16:44
Show Gist options
  • Save maravedi/176beb8245bab83e41d70aa830903618 to your computer and use it in GitHub Desktop.
Save maravedi/176beb8245bab83e41d70aa830903618 to your computer and use it in GitHub Desktop.
Formulas to split up a UTC timestamp into date and time
Say you have this timestamp: 2019-01-17T14:04:47.4927812
Say you want to split it up in Excel (you can't use a PowerShell ALL the time, right?), then here's what I figured out.
Assumptions:
The timestamp is in the first column, and has a header. For this example, it's in cell A2.
To get the date:
=LEFT(A2,10)
To get the time (without the sub-seconds):
=LEFT(RIGHT(A2,(LEN(A2)-11)), (LEN(A2) - FIND(".",A2) + 1))
And if you want to convert that time from UTC to EST, the full formula would be this (make sure the number format is right for that cell):
=LEFT(RIGHT(A2,(LEN(A2)-11)), (LEN(A2) - FIND(".",A2) + 1)) - 5/24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment