×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




This works great thanks!

Is it possible to ensure this functions properly even if a user does a CHGJOB DATFMT(*YMD) and then uses the SQL suggested below?

Problem is that the SQL is expecting the date to be a certain format MMDDYY or whatever. If the job format is changed to YYMMDD as is more common in IT, then the SQL fails.

Thanks!


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of CRPence
Sent: Monday, April 08, 2013 6:09 PM
To: midrange-l@xxxxxxxxxxxx
Subject: Re: SQL list *OUTFILE of DSPOBJD by date

Humans are very adaptable to deal with an /ugly/ date format such as
MMDDYY, even when a typical computer algorithm is not so amenable. Thus
the following is probably sufficient for most humans; i.e. little need
to recompose the 6-digit date [best when all date values are between
1940 and 2039]:

select ODLBNM, ODOBNM, ODOBTP, ODCDAT, ODOBTX
from QTEMP/DSPQRY
order by ODCCEN desc , right(ODCDAT, 2) desc
, left(ODCDAT, 4) , ODCTIM desc

If using *MDY for the DatFmt, and ignoring the ODCCEN is acceptable,
then the following expression is fairly succinct [all dates must be in
the 1940-2039 100-year window]:

date(insert(insert(ODCDAT, 5, 0, '/'), 3, 0, '/'))

Avoiding the 6-digit year format and the ignoring of the ODCCEN, to
ensure the date is processed to the correct century, the following
expression formulating a *USA date format is a bit longer:

date( insert( insert( ODCDAT, 3, 0, '/')
, 6, 0 , '/' concat digits(dec(ODCCEN+19, 2)) ) )

Regards, Chuck

On 08 Apr 2013 14:38, Stone, Joel wrote:
I would like to list the *OUTFILE of DSPOBJD by date.

Since DSPOBJD provides the incredibly ugly date format MMDDYY, I
would like to convert it to a date with year 99 going to the end
of the descending order.

What is a good method to do this?

Do I have to construct the date such as shown below?

But even then the year 99 pops to the top (it should be at the end).

I think I have to use DATE and CHAR and TRIM to build the date.

How do I force it to take MMDDYY and calc 1900 or 2000?

*MDY??

Is there a simpler, better way? (There must be :))

Thanks!

select ODLBNM,ODOBNM,ODOBTP
, substr(ODCDAT,5,2) || '-' || substr(ODCDAT,1,2)
|| '-' || substr(ODCDAT,3,2)
as CreateDate
, ODOBTX
from qtemp/dspqry
order by CreateDate desc

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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

This mailing list archive is Copyright 1997-2026 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.