Display date format in DD-MM-YYYY
Hello my friends,
I have a bit problem with date format, I need to display like this DD-MM-YYYY
I've put the objectscript like this : set DOB=$zd(paper.PAPERDob,15)
and the result is
.png)
Why It cannot show the full year, I mean why 99 or 95 why not 1999 or 1995 ?
Thank You
Best Regards,
Steven Henry
Comments
The code you used (set DOB=$zd(paper.PAPERDob,15)) most likely returns a two-digit year by default because $ZDATE defaults to using two-digit years for certain ranges unless a different option is explicitly set. For years like 1995 or 1999, $ZDATE shows the last two digits as 95 or 99. To display the full year, use the YearOpt parameter.
You can modify the code to explicitly specify four-digit years. Use the YearOpt argument in $ZDATE. The following example forces four-digit years:
set DOB=$ZDATE(paper.PAPERDob,15,,,4)
$ZDATE(hdate,dformat,monthlist,YearOpt)allows you to specifyYearOpt, where:4ensures the year is displayed as four digits.
- Format code
15corresponds toDD/MM/YYYY[1].
If your issue persists, ensure your locale settings align correctly with four-digit years expected in the display [1].
Sources:
WRONG advice !
only 2 commas after 15 !
Yes, we have to know that sometimes AI didn't give the right advice or solution
@DC AI Bot
set DOB=$ZDATE(paper.PAPERDob,15,,,4) is not working for me it still give the same result
set DOB=$ZDATE(paper.PAPERDob,15,,4)
will do it
1 comma less,
4 is the 4th parameter !!
see also doc:
https://docs.intersystems.com/iris20251/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS_fzdate
Great, it works,
Thank You @Robert Cemper
sometimes I thought it would be better to ask to someone than AI
Take a look at the documentation for %SYS.Date.SlidingWindow
you can try DOB=$ZDATE(paper.PAPERDob,15,,4)
u can also use $ZDATE(+$HOROLOG,4)
replace horolog with paper.PAPERDob