×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• 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.

(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,

(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);

(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??

How have you SET BUSDAYS?

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.

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:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!