How can I get the spreadsheet values with Python's gspread?
Suppose there is a cell that looks like 1/1 because m/d is specified as the cell display format, but actually contains 2024/1/1. Retrieving this cell using get_all_values() returns "1/1". I want the actual value "2024/1/1", not the value displayed on the sheet. What should I do?
I will omit the sheet acquisition part.
values = workbook.worksheet(sheet_name).get_all_values()
value = values[1][0] # 1/1 will be obtained

Issue and workaround:
From your showing image, script, and current value, I understood that you put a value of
2024/01/01into a cell "A2" as a date object. And, the cell value is shown as1/1with the number format.In the current stage, when this cell value is retrieved by Sheets API,
1/1is retrieved as the default request ofvalueRenderOption: FORMATTED_VALUE. WhenvalueRenderOptionis changed toUNFORMATTED_VALUE, the serial number of45292is retrieved. Unfortunately, in the current stage, the inputted value of2024/01/01cannot be directly retrieved. So, it is required for the following flow.valueRenderOption: UNFORMATTED_VALUE.When this flow is reflected in your showing script, how about the following modification?
Modified script:
In the case that the cell "A2" has
2024/01/01of the date object and1/1is shown by the number format, when this script is run,formattedis2024/01/01.from datetime import datetimeis used.References: