Q

RPG-free routine to calculate dates

One user writes, "I thought that I saw somewhere an RPG-free routine using %DATE (bif) to calculate the day of the week. For example, MON, TUE, etc.? I need to place the day on a screen." Development expert John Blenkinsop responds.

I thought that I saw somewhere an RPG-free routine using %DATE (bif) to calculate the day of the week. For example,...

MON, TUE, etc.? I need to place the day on a screen.

Try this from Midrange.com.

 
*// 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 

More on this topic

The Best Web Links: tips, tutorials and more.

Visit the ITKnowledge Exchange and get answers to your developing questions fast.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

 

This was last published in August 2005

Dig Deeper on iSeries application development tools

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close