A date read from JSON is off by some hours
A timestamp such as "2026-09-25T12:30:00Z" arrives in VBA as 14:30, or a date written to
JSON appears shifted in another system.
Environment
All versions of WKL Office JSON.
Cause
- Reading: a time with a zone (
Zfor UTC,+02:00) is converted according toJDoc.DateZone. The defaultjdzLocalconverts to the local time of Windows, so12:30Zbecomes14:30in Central European Summer Time. This is correct when the value is compared withNow(), but not when the database stores UTC. - Writing: a VBA
Datehas no zone and is written without one. A receiving system that assumes UTC reads a local time as UTC.
Resolution
- For databases that store UTC, set
doc.DateZone = jdzUtcbefore reading. - To keep times as written, set
doc.DateZone = jdzAsWritten. - Before writing to a system that expects UTC, convert the local time to UTC in VBA and append the zone to a string yourself, for example
doc.SetValue "$.at", Format(utcTime, "yyyy-mm-dd\Thh:nn:ss") & "Z".
en/wiki/msaccess/json/troubleshooting/date-shifted.txt · Zadnja sprememba: uporabnika Wolfgang van der Stille