cache basics
how do you change a date format to dd-MMM-YYYY in cache
Comments
hello
you can try this code w $TRANSLATE($ZD($H,2)," ","-")
What is your starting format?
Hi
If the Ens package is available to you, then I find very useful theConvertDateTime() method of the Ens.Util.Time class.
For example, if I want to convert this date: “20181220” to “20-12-2018”, then I use the ConvertDateTime() method like this:
SET ConvertedDt =##class(Ens.Util.Time).ConvertDateTime("20181220","%Y%m%d","%d-%m-%Y")
The patterns that I use more frequently are:
%Y year including the century, as a 4-digit number (0000-9999)
%y year within a century as a number (00-99)
%m month as a 2-digit number (01-12)
%#m month as a number (1-12) without leading zeros
%d day of the month as a 2-digit number (01-31)
%#d day of the month as a number (1-31) without leading zero
%H hour in 24-hour format as a 2-digit number (00-23)
%M minute as a 2-digit number (00-59)
%S second as a 2-digit number (00-60) (60 for leap seconds)
%N fractional second in milliseconds as number (000-999)
You can read more details about the Ens.Util.Time class including the full list of the supported patterns here:
I hope it helps.
Regards
Stelios