cache basics

Caché

how do you change a date format to dd-MMM-YYYY in cache

  • 0
  • 1
  • 316
  • 1
  • 3

Answers

hello

you can try this code w $TRANSLATE($ZD($H,2)," ","-")

Hi

If the Ens package is available to you, then I find very useful the ConvertDateTime() 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:

https://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=ENSLIB&CLASSNAME=Ens.Util.Time

I hope it helps.

Regards

Stelios

Comments