+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Determine Day of Week in RPG

  1. #1
    Guest.Visitor Guest

    Default Determine Day of Week in RPG

    Anyone know of an easy way to determine the day of week given a date in YYYYMMDD format? TIA, Chuck Ackerman

  2. #2
    B.Myrick Guest

    Default Determine Day of Week in RPG

    Chuck, Use the SEARCH facility at the top of the forum screen. Look for: "Day of Week". This produced 50 hits. There are some good examples there. -bret

  3. #3
    Guest.Visitor Guest

    Default Determine Day of Week in RPG

    Search the www for Zeller's Congruence; No kidding... it can be coded easily even in RPG. I tested it against rexx dates over the 400 year cycle of the Gregorian calendar and it proved correct. It's also referred to by W. F. Schindler in his book. bobh

  4. #4
    Guest.Visitor Guest

    Default Determine Day of Week in RPG

    Determine a base date that you know the weekday of (Jan 1, 2000 is a Sat), use the SUBDUR opcode to find the number of days difference, divide by 7 and use the remainder with 0=Sat, 1=Sun....

  5. #5
    Guest.Visitor Guest

    Default Determine Day of Week in RPG

    That's good, if you know the DOWK for 01 Jan of every year and the day number of the date in question. bobh

  6. #6
    D.Handy Guest

    Default Determine Day of Week in RPG

    John, "...and use the remainder with 0=Sat, 1=Sun..." And don't forget to first check if the remainder < zero, and if so, to add 7. This simple addition handles the cases where the request date is prior to the base date. Doug PS - Do you really want 0=Saturday? That seems unusual. Choose your base date to get the desired day to be a remainder of zero.

  7. #7
    Guest.Visitor Guest

    Default Determine Day of Week in RPG

    Hi, I solved this as follows. Write a CLP with these statements in it : CRTDTAARA DTAARA(&RTNLIB/TSBDAYNAME) TYPE(*CHAR) + LEN(15) TEXT('BACKUP : Temporary dataarea + for retrieval dayname') STRREXPRC SRCMBR(TSBDAYNAME) SRCFILE(&RTNLIB/TSBREXX) Then write a REXX-proc. with this in it : /************************************************** ****************/ /* Program-id : TSBDAYNAME */ /* Written by : Rob Baartwijk */ /* Description : Retrieve name of current day, store it in */ /* DTAARA TSBDAYNAM. */ /************************************************** ****************/ ARG RTNPARM RTNPARM=DATE('W') 'CHGDTAARA TSBDAYNAME' RTNPARM After the rexx-procedure has run you will find the name of the day in the dataarea(e.g. MONDAY, TUESDAY, etc.) No more calculations, no more startdates, no more exceptions ! HTH, Rob.

  8. #8

    Default Determine Day of Week in RPG

    Search on CEEDAYS. There are three "CEE" APIs that are specifically designed for this purpose. Dave

  9. #9
    Guest.Visitor Guest

    Default Determine Day of Week in RPG

    Rob, Even simpler (for your requirement) which is different to Chuck's : RTVSYSVAL QDAYOFWEEK David

  10. #10
    Guest.Visitor Guest

    Default Determine Day of Week in RPG

    But David, that's cheating !!!!!! LOL! This systemvalue is not present on every version of OS/400 I believe. So I just came up with an alternative programming-approach. But of course, if someone is really looking for a solution, yours is the easiest/newest/simplest. G'Day, Rob.

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Replies: 2
    Last Post: 03-04-2008, 03:15 PM
  2. How to determine if a folder is empty
    By Guest.Visitor in forum CL
    Replies: 5
    Last Post: 12-06-2005, 09:57 AM
  3. System Name - how to determine?
    By Guest.Visitor in forum RPG
    Replies: 1
    Last Post: 12-12-2002, 09:11 AM
  4. determine day of week
    By Guest.Visitor in forum General
    Replies: 0
    Last Post: 11-22-2002, 12:26 PM
  5. determine day of week
    By Guest.Visitor in forum Web Languages
    Replies: 3
    Last Post: 11-22-2002, 12:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts