|
I "assumed" that the article was going to be one of those suggestions tohttp://ibmsystemsmag.blogs.com/idevelop/2011/07/jon-and-susan-get-educated.h
do something like
MYFILE
KEYFIELD
DATAFIELD1
DATAFIELD2
...
DateFieldNbrmmddccyy
...
and create a related table
MYFILE2
KEYFIELD
DateFieldForReal
OtherNewFieldsAsNeeded
...
But it wasn't. It was more of a load a new, unrelated table for use by
all tables using unreal dates. This new table may have columns like
RealDate
DateNbrCCYYMMDD
DateNbrMMDDCCYY
DateNbrJulian
DateNbr...
DateChar...
Then you preload the above table with all dates from 01-01-0001 through
maybe two hundred years into the future.
Then you would do a
Select KEYFIELD, DATAFIELD1, RealDate, DayOfWeek(RealDate)
From MYFILE left outer join DateTable on DateFieldNbrmmddccyy =
DateNbrMMDDCCYY
Of course, you could also have DayOfWeek in that table and avoid that
calculation also. Then there's month, etc. And if your shop has unique
stuff like fiscal period and whatnot you can cover that also.
And the pundits are saying that joining to the additional table may out
perform doing the calculations on the fly. Very interesting!
values days(date('2400-12-31'))
returns 876,582. So that's how many rows you might put into your table.
And probably all columns would have their own index
Rob Berendt
--
Group Dekko
Dept 1600
Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com
From: Luis Rodriguez <luisro58@xxxxxxxxx>
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Date: 07/06/2011 08:37 PM
Subject: Re: SQL Date function question
Sent by: midrange-l-bounces@xxxxxxxxxxxx
Jon,
Thanks for the link. It is not an obvious solution (maybe we are hardwired
to avoid creating extra tables) but, once you see the simplicity of it, it
seems the right way to go.
Thanks again,
Luis Rodriguez
IBM Certified Systems Expert - eServer i5 iSeries
--
On Wed, Jul 6, 2011 at 7:27 PM, Jon Paris <jon.paris@xxxxxxxxxxxxxx>
wrote:
Check out the SQL date reference in today's blog post Brad - personallyI'm
never going to bother wrestling with dates in SQL again. We'll bewriting
it up fully later but everything you need in that Redbook.
list
list
On Jul 6, 2011, at 5:06 PM, midrange-l-request@xxxxxxxxxxxx wrote:
I've got a program that uses dynamic SQL and I'm having a hard time
finding documentation for this, or to find out if it's even possible.
The file contains a date in the format MMDDCCYY. I need to compare
the year entered in a query with the year in the date.
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
To post a message email: MIDRANGE-L@xxxxxxxxxxxx--
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
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.