This seems to do the trick (I'm using Caché 2017.2, but I presume little has changed since?):
SET utc="2023-05-17T09:37:03.123456Z" SET loc=$ZDATETIME($ZDATETIMEH($ZDATETIMEH(utc,3,7),-3),3,7,6) ZWRITE utc,loc utc="2023-05-17T09:37:03.123456Z" loc="2023-05-17T10:37:03.123456Z"
The "SET loc=..." conversion works as follows:
The inner ZDATETIMEH converts ISO format to $H format The outer ZDATETIMEH converts UTC time (in $H format) to local time (again in $H format) The outermost $ZDATETIME converts $H format back to ISO format (the final 6 is the number of decimal places)
If you need to remove the ":-TZ" characters a $TRANSLATE will do that for you.
This seems to do the trick (I'm using Caché 2017.2, but I presume little has changed since?):
SET utc="2023-05-17T09:37:03.123456Z"
SET loc=$ZDATETIME($ZDATETIMEH($ZDATETIMEH(utc,3,7),-3),3,7,6)
ZWRITE utc,loc
utc="2023-05-17T09:37:03.123456Z"
loc="2023-05-17T10:37:03.123456Z"
The "SET loc=..." conversion works as follows:
The inner ZDATETIMEH converts ISO format to $H format
The outer ZDATETIMEH converts UTC time (in $H format) to local time (again in $H format)
The outermost $ZDATETIME converts $H format back to ISO format (the final 6 is the number of decimal places)
If you need to remove the ":-TZ" characters a $TRANSLATE will do that for you.