Mass cell convert on Google Spreadsheet - google-sheets

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.

Related

Query function behaving strange with dates in google sheets

Function which isn't working: =QUERY(A:B, "SELECT A WHERE B > " & D1, 0)
What it's looking at:
A
B
Strings
13 Feb 2023
Strings
18 Feb 2023
Strings
21 Feb 2023
Cell D1 =
10 Feb 2023
Trouble shooting:
The query is coming up no results. All dates are numbers, when I format them as numbers instead of dates it works, when I format them as DD MMM, it works, but when I format them as DD MMM YYYY it doesn't work and this is the format I need it in.
Question
Why is Query so sensitive to date formats?? I always use different date formats depending on the sheet and vlookup has no issue with this. Also why on earth would it just not accept one format? I really want to learn for future
for query you may use:
=QUERY(A:B, "SELECT A WHERE B > date'"&text(D1,"yyyy-mm-dd")&"'")
if you wish to avoid the query confusion; you may just go with simple filter Fx
=filter(A:A,B:B>D1)

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", "#"})))

Google Spread Sheet Script. Working with Dates

I am reading list of Google Sheet cells containing DateTime, using Google Apps Script.
The values in the cells are:
A1: Jul 26 13:00
A2: Jul 27 0:00
var dateValues = SpreadsheetApp.getActiveSheet().getRange("A1:A2").getValues();
However, values read are 1 hour behind. This is what I see in the debugger:
dateValues[0] = Wed Jul 26 2017 12:00:00 GMT+0200 (EET)
dateValues[1] = Wed Jul 26 2017 23:00:00 GMT+0200 (EET)
I guess this is a time zone issue, but I don't really understand the concept.
My time zone is currently (due to DTS) GMT + 3. Indeed, outside the DTS period it is GMT +2. The spread sheet time zone is Jerusalem GMT+2.
EET - don't underrated why it is being used.
Basically, I would expect to get in code the values with in the sheet.
What is the concept?
there are two ways to solved this
Use getDisplayValues() rather than getValues(). This will force to do some conversions, as getDisplayValues() returns strings not dates
make you script editor time zone match the sheet tz.
In my case the sheet was (GMT+2 Jerusalem), but the script editor was different (GMT+2 Moscow) for some reason.
Setting the script editor TZ, solved the problem.

Resources