Written by

Question Birun Balami · Dec 5, 2017

Getting Current Day in Cache

Hi Everyone,

I want to get current day name in cache. Does anyone know how to do that?

Comments

Dani Fibla · Dec 5, 2017

Hi Birun,

Try this 

w $ZD($H,12)
Tuesday

Regards.

0
Alexey Maslov  Dec 6, 2017 to Dmitry Maslennikov

Just 2c to add. If a "national" locale is effective, e.g.

%SYS>zw ^%SYS("LOCALE","CURRENT")
^%SYS("LOCALE","CURRENT")="yruw"

and the setting was done before Caché restart:

%SYS>set ^SYS("NLS","Config","LocaleFormat")=1

you will get your national day name if don't forget to set localeopt=0, e.g.

USER>f localeopt=0,1 w localeopt," ",$ZD($h,12,,,,,,,,localeopt),!
0 Среда
1 Wednesday

It's also possible to achieve the same overriding format defaults for the current process (see $ZDATE description for details). I emphasized the need in Caché restart just because didn't find it in docs.

0
Kevin Furze · Dec 5, 2017

not sure which "day" you want, so try this and you can take your pick of the format you want.

f i=1:1:13 w !,i,"-",$zd($h,i)

0
Dmitry Maslennikov  Dec 6, 2017 to Alexey Maslov

For current process

USER>f fmt="enuw","rusw","current","" do ##class(%SYS.NLS.Format).%New(fmt) w !,fmt,?10,$zd($h,11),?15,$zd($h,12)
 
enuw      Wed  Wednesday
rusw      Сре  Среда
current   St   středa
          Wed  Wednesday

Or for all new processes, without restart

%SYS>write $zd($h,12)
Wednesday
%SYS>Set ^SYS("NLS","Config","LocaleFormat")=1
 
%SYS>write $zd($h,12)
Wednesday
%SYS>Do Locale^NLSLOAD("rusw")
 
%SYS>write $zd($h,12)
Среда
0
Alexey Maslov  Dec 7, 2017 to Dmitry Maslennikov

This option: 

$ZD($h,12,,,,,,,,localeopt)

seems to be more safe as switching the default representation for $ZD($h,12) may ruin already existing functionality that is expecting English days' names.

To be honest, I'd prefer application level localization, just because not all possible languages are supported by Caché.

0
Dmitry Maslennikov · Dec 5, 2017

Look at the documentation, there are some formats available to use in the $zdate function. Where 11 (abbreviated) and 12(full) looks like what you need.

write $zdate($h, 11)
Tue

Write $zdate($h, 12)
Tuesday
0