title: SQL modify and replace json string-value
body: <p>Is it possible to change the values of sub-json-data in the following manner?</p>
  
  <pre><code>DECLARE @json NVARCHAR(MAX) = "{"message":"Machine is down","machineId":"165ACE37-4E2C-4D44-9D14-F9E2CB2C2C13","machineName":"1501","ipAddress":"192.168.150.101","time":"2018-05-20T18:33:23.171"}"
  
  SELECT * FROM OPENJSON(@json) 
  WITH (  message varchar(200) '$.message',
      machineId varchar(200) '$.machineId',
      machineName int '$.machineName',
      ipAddress varchar(200) '$.ipAddress',
      LocalTime datetime2(7) '$.time'
  ) AS ChangeTime
  </code></pre>
  
  <p>I want to change the LocalTime variable i created and then replace the current one.</p>
  
  <p>I want to remove two hours from the $.time parameter. </p>
  
  <p>Something like this: </p>
  
  <pre><code>UPDATE Table SET ChangeTime.LocalTime = DATEADD(hour,-2,ChangeTime.LocalTime)
  </code></pre>
  
  <p>Input: <code>" time":"2018-05-20T18:33:23.171"</code></p>
  
  <p>output:
  <code>"time":"2018-05-20T16:33:23.171"</code></p>
  
  <p>How would i accomplish this?</p>