Question
· Sep 2

How to convert date in "YYYY-MM-DDTHH:MM:SSZ" format to "yyyymmddhhmmss" format?

I'm trying to convert date - 2023-09-28T20:35:41Z to BST/GMT format. I tried with $ZDT($ZDTH("2023-09-28T20:35:41Z",-2),8,1) but it's giving the output as '19700101 01:33:43' and looks link the date format in $ZDTH specified is wrong. Any inputs or solution would be appreciated.   

Discussion (4)2
Log in or sign up to continue

Jumping off of the answer I have given here only earlier today and being in a country currently observing(?) BST, you'll want to use the following approach:

  1. Use $ZDATETIMEH with the dformat of  3 and tformat of 7 (Note for the tformat that it's expecting the input as UTC, which is what you have with your source timestamp)
  2. Use $ZDATETIME with the dformat of 8 and tformat of 1
  3. Realise quickly that the tformat includes separators between the date and time, and within the time itself, so wrap it all in $ZSTRIP to remove all punctuation and whitespace...

Basically this:

WRITE $ZSTRIP($ZDATETIME($ZDATETIMEH("2023-09-28T20:35:41Z",3,7),8,1),"*P")


Gives you this:

And demonstrating this for a date that isn't affected by BST you'll note that the time stays the same as the input because BST isn't in effect in the winter, taking the timezone I'm in back to GMT:

I hope this helps!