How to separate timestamp in google sheet - google-sheets

In googlesheet, I have a timestamp in this format
March 12, 2021, 9:54 PM
I need to split it to
2021-03-12
And in another column:
9:54 PM
Is there any way to do it?

If you are using US locale for GS then use following formulas for date:
=TEXT(INDEX(SPLIT(A1,","),,{1,2}),"yyyy-MM-dd")
and for time:
=TEXT(INDEX(SPLIT(A1,","),,3),"h:mm AM/PM")

Related

Extract date from text written timeslot

Trying to extract the date from the written string Thursday, Aug 25, 2022 2:00 PM-2:30 PM which should result in a date value of Thursday, Aug 25, 2022 2:00PM (or any date & time format).
Assuming the string is located in cell G2, I tried =TRIM(MID(G2,FIND(" ",G2),FIND(" ",G2,FIND(" ",G2)+1)-FIND(" ",G2))) and all I get is: Aug.
try:
=REGEXEXTRACT(A1, "\b[A-z]{3} \d+. \d+\b")

Google Sheets formula to convert FROM ordinal dates TO standard dates

I am looking for a formula that will automatically convert a column of ordinal date/time values into standard date/time values.
July 1st 2022 6:48:49 pm
July 2nd 2022 10:03:35 am
July 3rd 2022 5:41:12 pm
July 4th 2022 2:44:13 pm
I need to get those reformatted to eliminate the st, nd, rd, and th portions.
Sheet
You can use
=INDEX(IF(A2:A7="",, REGEXREPLACE(A2:A7,"st|nd|rd|th","")*1))
You can then format as you like
(Do adjust the formula according to your ranges and locale)
Functions used:
INDEX
IF
REGEXREPLACE

How to convert a text string in Google Sheets to date format

I have a column with dates and time formatted like this in each cell:
Thursday, Jan 21, 2021 4:30 PM-5:00 PM
I want to split this across two columns so that the first column has "DD/MM/YY" and the second has the timeslot.
So it would go from being a cell with:
Thursday, Jan 21, 2021 4:30 PM-5:00 PM
to two cells:
21/01/21 4:30 PM-5:00 PM
What formula can I use in Google Sheets to achieve this?
Another suggestion (which assumes here that your raw data runs A2:A):
=ArrayFormula(IF(A2:A="",,SPLIT(REGEXREPLACE(A2:A,"^\w+, (.+\d) (\d.+$)","$1~$2"),"~")))
This will leave your dates in the first column as numeric raw dates rather than as text, so you'd be able to use them in calculations and comparisons later. Just select the first column of the results (i.e., those raw dates, showing as numbers in th 40000 range) and format the entire column (Format > Number) in the date format you prefer.
use:
=INDEX(IFNA(TEXT({REGEXEXTRACT(A1:A, ", (.+\d{4})")*1,
REGEXEXTRACT(A1:A, "\d{4} (.+)")}, {"dd/mm/yyyy", "#"})))

How to work with raw date format in Google Sheets

I'm using Zapier to input timestamps of emails to Google Sheets. The format I'm seeing in Google Sheets is:
Wed, 28 Jun 2017 21:02:51 +0000 (UTC)
Is there a way to either change this (in Google Sheets) to 2017-06-28 21:02:51 or to help date-related functions to understand this format?
You should be able to extract date from string:
=DATEVALUE(REGEXEXTRACT("Wed, 28 Jun 2017 21:02:51 +0000 (UTC)","\d+ [A-Za-z]{3} \d{4}"))
REGEXEXTRACT part extracts "28 Jun 2017". Then format the result as date.
Edit:
Getting closer :) Error DATEVALUE parameter '28 Jun 2017' cannot be
parsed to date/time.
I think this is bacause of your regional settings.
Option: writing script, my solution wont work.
Option: Change File → Regional Settings to US.
Option: modify the formula so it replaces english names of monthes into their numbers. This would produce ugly big formula.

Mass cell convert on Google Spreadsheet

I have a really big spreadsheet in google docs. I have a collumn with time in UTC format. For instance (2013, 10, 14, 12, 17) for 14 Oct 2013, 12:17 am
I want to change it to ISO 8601. I have started to change them one by one, but the data is huge. Is there any other way to do it automatic?
If you want to turn (2013, 10, 14, 12, 17) (assumed in A1) into a more conventional format:
=SPLIT(mid(A1,2,len(A1)-2),",")
to populate B1:F1 then:
=date(B1,C1,D1)+(E1+F1/60)/24
to convert to a date time index recognised by Google Sheets. The result might be formatted:
dd MMM yyyy, HH:mm AM/PM
to show: 14 Oct 2013, 12:17 PM
or formatted otherwise by choice (ISO 8601 does not require a unique format).
This does not attempt to address any strange convention for the likes of 12:17 (ie treats that as 17 minutes after noon, not after midnight) nor any time difference due to location.

Resources