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!
Comments
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.
Patty - just an FYI but I also had the same issue with ConvertDateTime by itself, and also had to use the extract function with it. Not sure why it doesn't seem to work by itself but thanks for the response with the working answer - I appreciate it!