Can anyone tell me how to go about calculating the business days between two dates? Is there a bif for the day of the week? Thanks
Unconfigured Ad Widget
Collapse
Announcement
Collapse
No announcement yet.
calculate business days between 2 dates
Collapse
X
-
The CEEDAYS API will return day of the week, but that will not necessarily get you to the business days.
You must also consider holidays, etc.
Establishing a file that hallmarks all non-business days is the only way you can make this work considering that every company has some minute differences.
Once you know how many non-business days occur in your range, you can subtract that from the result of the SUBDUR opcode.
Dave
-
Originally posted by kambam633 View PostCan anyone tell me how to go about calculating the business days between two dates? Is there a bif for the day of the week? Thanks
if it holds working days then a simply sql
select count(*) from calfile where Caldate between FromDate and Todate
Dave
Comment
-
We have a calendar file on our system that holds info against each date - its real date as an *iso value (eg.2010-11-03), its numeric value(eg.20101103), character value (eg '20101103' useful for chaining from legacy file dates). There is also a Y/N flag for weekends and another for Bank holidays. Then we can calc the no of total days, weekdays and business days (including shutdown between xmas and new year) thus:
/free
select count(caactdate) into :NoDays from calendarp
where caactdate between :fromdate and :todate;
select count(caactdate) into :NoDays from calendarp
where caactdate between :fromdate and :todate
and caweekend <> 'Y';
select count(caactdate) into :NoDays from calendarp
where caactdate between :fromdate and :todate
and cadayofyr < 360
and caweekend <> 'Y'
and cabankhol <> 'Y';
/end-free
Comment
Comment