Beniabdullah
21st July 2005, 13:04
Dear Friends,
How to count the days between two diff. date exclude Saturday and Sunday (working hours).
e.g :
Order Date : 15 July 05 (friday)
Receipt Date : 18 July 05 (monday)
days = order date - receipt date
= 1 (counted only for monday) due 16 Sat, 17 Sun.
Thank's in advance.
mark_h
21st July 2005, 14:03
Well the first thing that popped into my mind was to use the company calendar. You can use a formula like date>=date1 and date<date2 where the day type does not equal weekend (WND on our system) or day type does not equal holidays(if needed). Of course on our system we do not have a specific workcenter calendar everything falls into the ZZZ workcenter. I wonder if Baan has a routine.
Juergen
21st July 2005, 15:01
enclosed a small example to read the company calendar which I used in a script
function read.company.calendar.for.runtime()
{
orno.runt = 0
select tirou400.*
from tirou400
where tirou400._index1 inrange {"ZZZ",:tdsls040.odat}
and {"ZZZ",:orno.last.ddat}
and tirou400.ctod in (" 1"," 2") |Working day 1 (Mo-Th)
|Working day 2 (Fr)
order by tirou400._index1
selectdo
if tirou400.date <> orno.last.ddat then
orno.runt = orno.runt + 1
endif
selectempty
|* Work Center "ZZZ" not available
orno.runt = orno.last.ddat - tdsls040.odat
endselect
Hope this helps a little.
Juergen
mr_suleyman
21st July 2005, 16:47
I think that there is a no direct way to solve your problem. Because you exclude weekends. In our system , we construct days calendar and enter days of year because of factory works times. In this way , we can easily compare days with baan calender and solve problem like yours. As you know that days of week changes in every years. Therefore you must use other calender to compare with it.
May be , anyone know other solution. Take it easy .!
Good lucks...
avpatil
24th July 2005, 18:41
Hi,
You can use "blank" company calendar from tirou410 table and took the difference between the difference of cumlative working time. You can write your own DLL so that it will be used by any program. Baan have this somewhere as MRP and MPS uses the planning calendar. If you just want to get the working days excluding weekends you can do simple calucaltion for e.g say the difference between the date is say 30 days then the number of working days would be nearest lowest number that is multiple of 7 i.e 28 and then you can calculate working days as 28*5/7 + 2 = 22 days.
Arvind
fallguyjg
5th August 2005, 01:45
Beni,
Here's a function that uses company calendar to count days excluding weekends and holidays.
function long no.days.less.weekends(
domain tcdate date.f,
domain tcdate date.t )
{
| This function returns the number of days from date.f to date.t
| excluding weekends and holidays per the company calendar.
long no.of.days
if date.f = 0 or date.t = 0 or date.t < date.f then
return(-1)
endif
select count(*):no.of.days
from tirou400
where tirou400._index1 inrange {"ZZZ", :date.f}
and {"ZZZ", :date.t}
and ( tirou400.ctod = "WRK" or
tirou400.ctod = "FRI" )
selectdo
selectempty
return(-1)
endselect
return(no.of.days)
}
Our company calendar has day types "WRK" and "FRI" as work days.
Date : 08-05-05 [08:40] COMPANY CALENDAR Page : 1
Neways Inc. (MFG)-NEW Work Center: ZZZ Company Work Center Company : 100
--------------------------------------------------------------------------------
| | | | Type | |
------+------+----------+-----+--------+--------------------------------+-------
2005 | 1 | 01-02-05 | Sun | SUN | Sunday |
| | 01-03-05 | Mon | WRK | Normal Work Day |
| | 01-04-05 | Tue | WRK | Normal Work Day |
| | 01-05-05 | Wed | WRK | Normal Work Day |
| | 01-06-05 | Thu | WRK | Normal Work Day |
| | 01-07-05 | Fri | FRI | Friday |
| | 01-08-05 | Sat | SAT | Saturday |
Hope this helps,
fallguyjg
Beniabdullah
9th August 2005, 04:40
Hi FallGJ.. thank's
It's works now...