更新到 Google Sheets 時的日期/時間問題

Describe the problem/error/question

I am updating to google sheets using rotating variables. I have Workbooks named Sales - January 2026, and so on
inside those workbooks are sheets named 01,02,03, for the days of the month
I have my sales stats being pulled in, then I grab the sold date, change the date to do a google sheets search to find the workbook, then once it finds the workbook, it uses the sold date again to update the sheet (by name)
the issue is happening in the last step, if the date is 01/03/2026, it will always try and update the 02 sheet
it is like the date/time I am seeing in n8n is not what is really there
I made sure my time zone was set in the workflow and I double checked the server time zone, both are correct

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

    • platform: docker (self-hosted)
    • nodeJsVersion: 24.14.1
    • nodeEnv: production
    • database: postgres
    • executionMode: regular
    • concurrency: 1
    • license: enterprise (production)
    • consumerId: 6384698f-6660-45c3-b287-06c96943ef5e

那個差一錯誤通常是因為日期被轉換一次作為真實的 Date/timezone 值,然後被重複用作 sheet/tab 鍵。對於這個設置,我會將工作簿查詢和日期-tab 查詢設為兩個明確的字串輸出,並停止將 Date 物件傳入最終的 Google Sheets 節點。

一個安全的模式是:在更新節點之前,在 Set 節點表達式中建立類似 sold_day_key = DateTime.fromFormat($json.sold_date, 'MM/dd/yyyy', { zone: 'America/New_York' }).toFormat('dd') 的東西,然後將 sold_day_key 作為 sheet 名稱傳入。將時區交換為你的報表時區。也在同一節點中記錄原始 sold date + workbook 名稱 + tab 鍵,這樣你就能確切看到 01 如何變成 02

我可以將工作流程 JSON 轉換成確切的 Set/Code 節點加上一個小測試矩陣,如果你想要非同步處理的話。我的電郵是 oimrqs.ops@gmail.com

所以我建議你在嘗試選擇工作簿中的工作表之前,先執行 getDay 之類的操作,並且在轉換日期之前,也要遵循 @oimrqs_ops 的建議,明確傳遞時區。

好的 @djjace

我認為問題出在 Google Sheets 節點上。
n8n 在選擇分頁名稱之前,會將值轉換為實際的 DateTime。由於你的分頁只是日期識別碼,我不會在那裡使用 DateTime。我會直接從原始 Sold Date 字串建立工作表名稱,例如提取日期部分並在需要時填充,然後將該純字串作為工作表名稱傳遞。這樣可以將時區轉換排除在路由邏輯之外,應該能阻止 01 變成 02。