× 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 am not too familiar with SQL.

would this first statement go in the RPG code and where does it go?




________________________________
From: "rob@xxxxxxxxx" <rob@xxxxxxxxx>
To: RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
Sent: Wednesday, November 12, 2008 1:58:13 PM
Subject: Re: date processing for end of week

Today is Wednesday November 12, 2008.
select dayofweek_iso(current date) from sysibm/sysdummy1
returns 3
Friday would be 5.

select dayofweek_iso(current date),
  date(days(current date) + (5 - dayofweek_iso(current date)))
    as Friday
  from sysibm/sysdummy1
returns
....+....1.....+....2....+.
DAYOFWEEK_ISO  FRIDAY
            3  2008-11-14
********  End of data  ***

So, what happens if it's Saturday?  Do I have to use a CASE statement? No.
select dayofweek_iso('2008-11-15'),
  date(days('2008-11-15') + (5 - dayofweek_iso('2008-11-15')))
    as Friday
  from sysibm/sysdummy1
returns
....+.....1....+....2....+.
DAYOFWEEK_ISO  FRIDAY
            6  2008-11-14
********  End of data  ***

Your business logic can decide if you need to use DAYOFWEEK or
DAYOFWEEK_ISO to determine what week Sunday is in.

Rob Berendt

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-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.