Color scheme: Dark
You are here: start » en » Documentation » Microsoft Access development tools » WKL Office JSON » WKL Office JSON how-to guides » How to: Read and write dates and times

How to: Read and write dates and times

Read ISO 8601 (RFC 3339 profile) dates and timestamps into VBA Date values and write Date values so that other systems read them correctly.

Solution overview

JSON has no date type; dates travel as ISO 8601 strings. GetDate (and JValue.DateValue) parse them. JDoc.DateZone decides what happens with a time that carries a zone (Z, +02:00). Writing a Date produces ISO 8601 without a zone.

Implementation

Dim doc As New JDoc
doc.LoadJson "{""due"": ""2026-09-25"", ""created"": ""2026-09-25T12:30:00Z""}"
 
Debug.Print doc.GetDate("$.due")          ' 25.09.2026
Debug.Print doc.GetDate("$.created")      ' 25.09.2026 14:30:00 in Central European Summer Time (jdzLocal)
 
doc.DateZone = jdzUtc
Debug.Print doc.GetDate("$.created")      ' 25.09.2026 12:30:00
 
doc.DateZone = jdzAsWritten
Debug.Print doc.GetDate("$.created")      ' 25.09.2026 12:30:00, zone ignored
 
doc.SetValue "$.shipped", Now             ' "2026-09-26T09:15:00" (no zone)
doc.SetValue "$.day", Date                ' "2026-09-26" (time 0 writes the date only)

Remarks

  • jdzLocal (default) converts with the time zone rules of Windows, including daylight saving time on the given date, so a value compares correctly with Now().
  • Choose jdzUtc when the database stores UTC, jdzAsWritten when the service writes local times with a zone that should be kept as displayed.
  • A service that expects UTC needs a UTC value: convert before writing, because a VBA Date has no zone and is written as it is.
  • A string that is not ISO 8601 raises jeTypeMismatch; with a default, the default is returned only for a missing path or null, not for a malformed date.
en/wiki/msaccess/json/how-to/dates-and-time-zones.txt · Last modified: by Wolfgang van der Stille