displaying a date in USA format in a display-file

Greetings, experts!

My RPG is reading a date from a database table and displaying it in a display file. By default, if I specify a data-type of L in the display-file, the data shows up in ISO format (YYYY-MM-DD).

But, my user would like to see the date in USA format (MM-DD-YYYY).

I realize I could easily translate it using SQL's CHAR function like this:

select char(myDate, USA)
  into :aChar10variable
  from MyTable

But, I'm wondering if I can specify something in the DSPF to just display the date in USA format.

Thanks for your help!
DaveSlash
LVL 18
Dave FordSoftware Developer / Database AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_b_hCommented:
Hi daveslash

Check out the Date Format keyword:
DATFMT(*MDY) or DATFMT(*USA)

Hope this helps!
Barry

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
daveslaterCommented:
Hi
when using sql you are returing a character not a date, the DATFMT only works on date fields.

in the C specs you need to use,

exec sql Set Option DatFmt = *USA ;

or you can compile the progrem with the relevent date format.

I tend to have the floowing standard spec in my sql programs

exec sql Set Option DatFmt = *Iso,            
                    DatSep = '/' ,            
                    CloSqlCsr = *EndMod,      
                    Commit = *None ,          
                    AlwBlk = *AllRead ;      


dave

Dave FordSoftware Developer / Database AdministratorAuthor Commented:
That'll do it. Thanks!
tliottaCommented:
...my user would like to see the date in USA format (MM-DD-YYYY).

Is this the only user of this function? Keep in mind that a DSPF date field can specify DATFMT(*JOB). Different users can see the same field in different formats. The same job can see it in different formats by running CHGJOB DATFMT(*ddd) DATSEP(*sss).

Tom
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IBM System i

From novice to tech pro — start learning today.