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




Even the formula and the algorithm that you posted has to have a reference
date to determine what a Sunday is (ie 0 = Sunday).  There is a basic
argument in this thread, if you are looking for a day of the week there
must be somewhere in the course of calculation a starting point, the fact
that you can't see it doesn't mean it doesn't exist.

MarK A McCarty
AS/400 Programmer/Developer
Navy Exchange Service Command

quote for the day:
"Any person engaged in small business in America would be amazed looking at
this. Their jaws would drop at the money farmers receive."

- KEITH COLLINS, Agriculture Department economist, on government subsidies.


                                                                                
                                        
                    "Wills, Mike N.                                             
                                        
                    (TC)"                    To:     "'RPG400-L@midrange.com'" 
<RPG400-L@midrange.com>                  
                    <MNWills@taylorco        cc:                                
                                        
                    rp.com>                  Fax to:                            
                                        
                    Sent by:                 Subject:     RE: Can I get the Day 
of the week?                            
                    owner-rpg400-l@mi                                           
                                        
                    drange.com                                                  
                                        
                                                                                
                                        
                                                                                
                                        
                    05/16/2001 10:41                                            
                                        
                    AM                                                          
                                        
                    Please respond to                                           
                                        
                    RPG400-L                                                    
                                        
                                                                                
                                        
                                                                                
                                        




There is a mathematical formula for getting the day of the week:

D = Day
M = Month
Y = the last two digits of the year
C = Century

((d + y) - (2 * c) + (y / 4) + (c / 4) + ((13 * m - 1) / 5)) % 7 = Day

For the Day: 0 = Sunday, 1 = Monday, etc.
For some reason my program is a day off right now but I am positive I had
it
working before. I haven't taken the time to debug it yet. This was done in
C++ on a PC. I need to double check my formula.

But with this formula it doesn't depend on a known date. I don't know if it
could cause problems, I just remember people keep on saying to NOT
hard-code
anything in if possible (although I am sure many of us do anyway). This is
a
formula that my instructor gave me and I have seen it on the web. Then, if
you (for some weird reason) need a day from the 1600's you can get it.

-----Original Message-----
From: DeLong, Eric [mailto:EDeLong@Sallybeauty.com]
Sent: Wednesday, May 16, 2001 8:51 AM
To: 'RPG400-L@midrange.com'
Subject: RE: Can I get the Day of the week?


No. I can't see that that's a problem. Personally, I can't see how one
could
determine the DOW without some sort of known date. These DOW functions are
both simple and effective. What's the problem?

Eric DeLong

-----Original Message-----
From: Wills, Mike N. (TC) [mailto:MNWills@taylorcorp.com]
Sent: Wednesday, May 16, 2001 8:30 AM
To: 'RPG400-L@midrange.com'
Subject: RE: Can I get the Day of the week?


The one problem I have with most of these suggestions is that the date is
then dependant upon a known date. Doesn't other people see something wrong
with this?

Mike

-----Original Message-----
From: boldt@ca.ibm.com [mailto:boldt@ca.ibm.com]
Sent: Wednesday, May 16, 2001 7:12 AM
To: rpg400-l@midrange.com
Subject: Re: Can I get the Day of the week?


From: "Christopher J. Devous" <cdevous@antigua.com>
Subject: RE: Can I get the Day of the week?
Christopher wrote:
>Try this, it's based on the famous "Doomsday" algorithm by JH Conway:
>
>    100
**************************************************************************
>    200       ***
>    300       ***      Program Name --  DOWK
>    400       ***      Description  --  Calculate Day of Week from
Gregorian
>    500       ***                       Date
>    600       ***      Author       --  Christopher J. Devous

As much as I respect John Horton Conway, RPG programmers can't do
day of week computation much shorter than with this procedure:

 //\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//
 // Procedure:  DayOfWeek                                           //
 // Purpose:  Determine the day of week for a particular date       //
 // Parameters:                                                     //
 //    I: dt   -- date                                              //
 // Returns:                                                        //
 //    0..6    -- 0=Sunday, 1=Monday, 2=Tuesday, etc.               //
 // Notes:                                                          //
 //    January 5, 1800 is a Sunday.  This procedure only works for  //
 //    dates later than 1800-01-05.                                 //
 //\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//
P DayOfWeek       b
D DayOfWeek       pi            10i 0
D   dt                            d   value datfmt(*iso)
 /free
    return %rem (%diff (dt: d'1800-01-05': *days): 7);
 /end-free
P DayOfWeek       e





Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator:
david@midrange.com
+---
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator:
david@midrange.com
+---

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator:
david@midrange.com
+---
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator:
david@midrange.com
+---





**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.