Question Smythe Smythee · Jun 23, 2023

Dateconversion

Hi Community,

I need to convert date 1997-08-09 10:38:39.700000000 into this format 1997-08-09T10:38:39Z 

I have tried using all date function  $ZDH,$ZDT no luck can anyone help me to convert this into required format.

Thanks,

Smythee

Product version: Ensemble 2018.1
$ZV: Cache for Windows (x86-64) 2018.1.1 (Build 312_1_18937U) Fri Apr 26 2019 17:58:36 EDT

Comments

Alex Woodhead · Jun 23, 2023

$Extract ($E) and $Translate ($TR) can provide a string manipulation

> set inDate="1997-08-09 10:38:39.700000000"
> set outDate=$TR($E(inDate,1,19)," ","T")_"Z"
> write !,outDate
1997-08-09T10:38:39Z

So steps are:

  • Grab the first 19 characters
  • Convert space " " to "T"
  • Append a "Z" to the end

Ignore if already the case, but would also recommend familiarity with $Piece, $Select and "[" (Contains operator) . $Find can also be efficient in string searches.

0
Smythe Smythee  Jun 23, 2023 to Alex Woodhead

Yes thank you,

Can we do that by using date function $ZDATE,$ZDATEH,$ZDATETIMEH?

0
Smythe Smythee  Jun 30, 2023 to Stuart Strickland

Thank you 

Can you help me understand Why we used  $ZDT($ZDTH(timeAndDate,3,9),3,7)  3,9 and 3,7 while converting 

Thanks,

Smythee

0