Thanks Al - Going back to the days of the DFU LIST command, I have been
one of the biggest proponents of teaching users how to effectively use
the Query tools.
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Al Mac Wheel
Sent: Wednesday, February 20, 2008 10:53 PM
To: Midrange Systems Technical Discussion
Subject: Re: Need example of calculating the #days between 2 dates in
WRKQRY
We have fields in the format CCYYMMDD
They are numbers in which all zeros, all nines are valid contents for
example the date Feb 21 is in there as 20080221 If your data is in a
different format, you may have to adjust my ALGORITHM
DA = DIGITS(CCYYMMDD)
If the name of the original field was CCYYMMDD and if it was numeric,
then the result field DA now has the same data in alpha string format
... stuff has to be in that data type to do content manipulation.
DT = DATE(SUBSTR(DA,5,2)||'/'||
SUBSTR(DA,7,2)||'/'||
SUBSTR(DA,3,2))
The vertical lines are concatenating the substrings of pairs of digits
to put the data in the form MM/DD/YY and redefine it as an IBM ISO Date
Type Format so that we can do date math on this result
Having done this with several different date fields we can now do things
in query/400 like:
DAYS_DIFF = DAYS(DT_NEW) - DAYS(DT_OLD)
where a positive # is days into the future and a negative # is days into
the past
TODAY = CURRENT(DATE)
gets us today's date in mm/dd/yy formt ... the date the query got run
TOMORROW = CHAR(CURRENT(DATE)) + 1 DAY(ISO) or TOMORROW =
DAYS(CURRENT(DATE)) + 1 YEAR_AGO = CURRENT(DATE) - 1 YEAR DAYS_AGO =
DAYS(TODAY) - DAYS(DT_CHANGE) as in how many days ago this customer
order got shipped
Last day of month
= CURRENT(DATE) + 1 MONTH - DAY(CURRENT(DATE))
First day of month
= CURRENT(DATE) + 1 DAY - DAY(CURRENT(DATE))
You'll need to test this kind of stuff to make sure I transcribed it
correctly.
Al Mac Wheel
who uses Query/400 because everything is wanted yesterday
TIA
Don F. Cavaiani
IT Manager
Amerequip Corp.
920-894-7063
"It's amazing what you can accomplish if you don't care who gets the
credit." Harry S. Truman
--
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
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.
As an Amazon Associate we earn from qualifying purchases.