worksheet.format("A2:A", { "numberFormat": { "type": "DATE_TIME" }}) doesn't work for text

Viewed 2139

I'm trying to log temperature and humidity to a google spreadsheet using gspread and python. That works, however when I insert a row using the following code:

worksheet.append_row((datetime.datetime.now().strftime("%d-%m-%Y %H:%M:%S"), temp, humidity))

now for example cell 'A2' has the value: '12-05-2020 00:11:50 (Note the single quotation mark) I want the data to be represented in a chart. This cannot be done with the above value so I have to convert it to a date_time value.

worksheet.format("A2:A", { "numberFormat": { "type": "DATE_TIME" }})

I expect the entire column to be converted to Date Time. This doesn't convert the values with a single quotation mark.

I spend the whole day trying to get this to work but for some reason I can't seem to find a way to have a 'normal' date_time value added that Google Sheets recognizes as a date_time...

If I enter a (numeric) value manually in a cell in column A. The code to set the format works just fine. Also if I manually select the column and select he formatting from the menu it works fine with the gspread added date time rows.

I really want it to be done programmatically and not by hand of course. Any help is greatly appreciated.

1 Answers
Related