× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I confess to my ignorance. The problem was not with my dates or logic. It
was my assumption that interactive SQL would show the date values in the
file in format defined in the DDS. Nope. It shows them in the format set
in the Current SQL Session attributes.

Thanks for everyone's input and advice.


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Booth Martin
Sent: Wednesday, June 27, 2012 2:41 PM
To: RPG programming on the IBM i / System i
Subject: Re: I guess I don't know dates

Jon Paris (I believe it was Jon) explained it best, I thought. This is a
paraphrase, but it is what I took away:

"A date field knows what it is. You don't have to tell it; it already
knows.

You do have to tell it what you are giving it so it will know what to do
with your data, and you have tell it what you want back so that it can give
you the date the way you want it."





On 6/27/2012 11:13 AM, Thomas Garvey wrote:
I'm perplexed by something that must be very simple, yet I must be
ignorant.
I can't get date data type fields populated in a PF correctly.

I have a DDS physical file with date data type fields defined with
various date formats (*USA, *ISO, *MDY, *JUL, etc.). The fields that
permit use of the DATSEP parameter do have it specified.

This file is populated (by RPGLE program X) from another file with
numeric values in the form of YYYYMMDD. Program X has stand alone
date data type fields defined with each of the various formats and
separators (example below).

d DateMDY s d datfmt(*MDY )
mm/dd/yy
d DateMDYSlsh s d datfmt(*MDY/)
mm/dd/yy
d DateMDYDash s d datfmt(*MDY-)
mm-dd-yy
d DateMDYPerd s d datfmt(*MDY.)
mm.dd.yy
d DateMDYComm s d datfmt(*MDY,)
mm,dd,yy
d DateMDYAmph s d datfmt(*MDY&)
mm dd yy
d DateDMY s d datfmt(*DMY)
dd/mm/yy
d DateDMYSlsh s d datfmt(*DMY/)
dd/mm/yy
d DateDMYDash s d datfmt(*DMY-)
dd-mm-yy
d DateDMYPerd s d datfmt(*DMY.)
dd.mm.yy
d DateDMYComm s d datfmt(*DMY,)
dd,mm,yy
d DateDMYAmph s d datfmt(*DMY&)
dd mm yy
d DateYMD s d datfmt(*YMD)
yy/mm/dd
d DateYMDSlsh s d datfmt(*YMD/)
yy/mm/dd
d DateYMDDash s d datfmt(*YMD-)
yy-mm-dd
d DateYMDPerd s d datfmt(*YMD.)
yy.mm.dd
d DateYMDComm s d datfmt(*YMD,)
yy,mm,dd
d DateYMDAmph s d datfmt(*YMD&)
yy mm dd
d DateJUL s d datfmt(*JUL)
yy/ddd
d DateJULSlsh s d datfmt(*JUL/)
yy/ddd
d DateJULDash s d datfmt(*JUL-)
yy-ddd
d DateJULPerd s d datfmt(*JUL.)
yy.ddd
d DateJULComm s d datfmt(*JUL,)
yy,ddd
d DateJULAmph s d datfmt(*JUL&)
yy ddd
d DateISO s d datfmt(*ISO)
yyyy-mm-dd
d DateISODash s d datfmt(*ISO-)
yyyy-mm-dd
d DateUSA s d datfmt(*USA)
mm/dd/yyyy
d DateUSASlsh s d datfmt(*USA/)
mm/dd/yyyy
d DateEUR s d datfmt(*EUR)
dd.mm.yyyy
d DateEURPerd s d datfmt(*EUR.)
dd.mm.yyyy
d DateJIS s d datfmt(*JIS)
yyyy-mm-dd
d DateJISDash s d datfmt(*JIS-)
yyyy-mm-dd

So, my program X logic moves the numeric value (in YYYYMMDD format)
into the DateISO field (defined as *ISO) and then moves the DateISO
into each of the stand alone fields shown above. The resulting values
are all correct as defined. That is, they contain exactly what they
should contain (the same date value, but in the field's format and
separator). This is verified using debugger.

However, when these values are then moved into the fields as defined
in the DDS PF (definition example shown below), they all get *MDY.
Doesn't matter how they are defined in the DDS.
A DUSASLSH L DATFMT(*USA)
A COLHDG('Date' 'USA Slash')
A DISODASH L DATFMT(*ISO)
A COLHDG('Date' 'ISO Dash')
A DEURPERD L DATFMT(*EUR)
A COLHDG('Date' 'EUR Perd')
A DMDYSLSH L DATFMT(*MDY)
A DATSEP('/')
A COLHDG('Date' 'MDY Slsh')
A DMDYDASH L DATFMT(*MDY)
A DATSEP('-')
A COLHDG('Date' 'MDY Dash')
A DMDYPERD L DATFMT(*MDY)
A DATSEP('.')
A COLHDG('Date' 'MDY Perd')
A DMDYCOMM L DATFMT(*MDY)
A DATSEP(',')
A COLHDG('Date' 'MDY Comm')
A DMDYNONE L DATFMT(*MDY)
A DATSEP(' ')

What is up with that? What am I ignorant of? What am I missing?
There is no DATFMT specification in any H spec. The system's default
format
(QDATFMT) is MDY but I can't believe that is controling here.
I always thought moving a date data type field to another date data
type field simply changes the format of the value.

Straighten me out here, please.

Tom Garvey



--
Booth Martin
802-461-5349
http://www.martinvt.com

--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.