Change Date Format from YYYYMMDDHHMMSS to YYYYMMDD in a DTL
Greetings,
Is it possible to change the date format from YYYYMMDDHHMMSS to YYYYMMDD in a DTL? How?
I tried ConvertDateTime() without success.
I'm using Iris for Health
Thank you!
Product version: IRIS 2023.3
$ZV: 2023.1.3
I'm not sure why ConvertDateTime() failed; informat should be "%Y%m%d%H%M%S" and outformat "%Y%m%d" for your example transformation. Regardless, you can also use $EXTRACT(<sourcedate>,1,8). There's also the SubString() method in the DTL function list, which takes the same arguments.
Thank you Jeffrey!
Late in the day yesterday, I figure out this was missing in my configuration: $e
I was able to set up ConvertDateTime function correctly like this:
ConvertDateTime($e(source.{PID:DateTimeofBirth},1,8))
$E is the shorthand version of $EXTRACT ...
ConvertDateTime(source.{PID:DateTimeOfBirth},"%Y%m%d%H%M%S","%Y%m%d") should work just fine.$E(source.{PID:DateTimeOfBirth},1,8) by itself should provide the same result.
But ConvertDateTime($e(source.{PID:DateTimeofBirth},1,8)) is basically taking the 8-digit date returned from $E() and converting it without any input and output patterns ... which gets you the exact same 8-digit date.