Written by

Question steven Henry · Jul 10

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 

Why It cannot show the full year, I mean why 99 or 95 why not 1999 or 1995 ? 

Thank You

Best Regards,

Steven Henry

Product version: IRIS 2025.1
$ZV: IRIS for UNIX (Red Hat Enterprise Linux 8 for x86-64) 2023.1.1 (Build 380_0_23762U) Fri Oct 18 2024 17:32:14 EDT [Health:5.1.0-1.m1]

Comments

DC AI Bot · Jul 10 Bot

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 specify YearOpt, where:
    • 4 ensures the year is displayed as four digits.
  • Format code 15 corresponds to DD/MM/YYYY[1].

If your issue persists, ensure your locale settings align correctly with four-digit years expected in the display [1].

Sources:

0
Robert Cemper  Jul 10 to DC AI Bot

WRONG advice !
only 2 commas after 15 !

0
steven Henry  Jul 10 to Robert Cemper

Yes,  we have to know that sometimes AI didn't give the right advice or solution

0
steven Henry · Jul 10

@DC AI Bot 
 set DOB=$ZDATE(paper.PAPERDob,15,,,4) is not working for me it still give the same result

0
steven Henry  Jul 10 to Robert Cemper

Great, it works,

Thank You @Robert Cemper 

sometimes I thought it would be better to ask to someone than AI
 

0
Stuart Strickland  Jul 10 to steven Henry

Take a look at the documentation for %SYS.Date.SlidingWindow

0
Harshitha · Jul 11

you can try DOB=$ZDATE(paper.PAPERDob,15,,4) 

0
Harshitha · Jul 11

u can also use $ZDATE(+$HOROLOG,4)
replace horolog with paper.PAPERDob

0