×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Calculate Business Day

Calculate Business Day

Calculate Business Day

(OP)
I have a problem calculating business day because it is short on one day:

For example:
TODAYDATE/WYYMD=&BEG;
DIFF/I8=DATEDIF(TODAYDATE, ENDDATE, 'BD');

Suppose TODAYDATE = 20041211 (Saturday)
ENDDATE = 20041218 (Saturday)  
The diff will come out as 4; however, I wanted to come out as 5.  The answer 5 will give me Monday, Tuesday, Wednesday, Thursday, and Friday.
I understand why it is giving me 4 because
20041217(Friday) - 20041213(Monday) = 4 days

Is there a code that work around this problem in order for me to get an answer of 5.
Thank you,

RE: Calculate Business Day

(OP)
I tried using the the method where if the enddate is on a weekday, then I'll increment the result to 1, but if it lands on a Saturday or Sunday, then I'll leave it alone.  However, I tried using the following function to determine the weekday, but it is not working for me. Am I doing something wrong?

ENDDATE/WYYMD=REQUESTED_DATE;
TODAYDATE/WYYMD=&BEG;
DIFF/I8=DATEDIF(TODAYDATE, ENDDATE, 'BD');
DAYIND/A12= DOWKL(ENDDATE, DAYIND);

RE: Calculate Business Day

(OP)
Actually, I try the following code, and it displays the day of the week now instead of blank, but the data is wrong...It seems to always be a day ahead.  So instead of Friday, it would have a result of Saturday.  Here is my code:

ENDDATE/I6YMD = REQUESTED_DATE;
DAYOW/A3 = DOWK(ENDDATE,DAYOW);

Any reason why??

RE: Calculate Business Day

How have you SET BUSDAYS?

RE: Calculate Business Day

What release are you running? I tried the following in releases 4.2.1 through 5.3:

CODE

-SET &BEG = '20041211';
-SET &ENDDATE = '20041218';
DEFINE FILE CAR
TODAYDATE/WYYMD WITH COUNTRY='&BEG';
ENDDATE/YYMD WITH COUNTRY= '&ENDDATE';
DIFF/I8 WITH COUNTRY=DATEDIF(TODAYDATE, ENDDATE, 'BD');
END
TABLE FILE CAR
PRINT TODAYDATE ENDDATE DIFF
IF COUNTRY EQ 'ENGLAND'
END

and got the following:

CODE

 TODAYDATE        ENDDATE         DIFF
 ---------        -------         ----
 SAT, 2004/12/11  2004/12/18         5

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close