>Hi Tomas! I just mean week days...
>
>Something like DateDiff() but only counting from monday to friday.
>
>I have a function in Delphi for that. I could make an UDF I think. I just
>wander if there is something already done. I thought it was something "very
>used"... probably is not?
I don't know whether this is common or not (can't remember anyone asking for it
before on this list), but if you don't care about special days it could be
implemented as simple as this:
execute block (fromdate date = :fromdate, todate date = :todate) returns
(weekdays integer) as
declare variable checkdate date;
begin
weekdays = 0;
checkdate = fromdate;
while (checkdate <= todate) do
begin
if (checkdate < todate - 6) then
begin
weekdays = weekdays + 5;
checkdate = checkdate + 7;
end
else
begin
if (extract(weekday from checkdate) between 1 and 5) then
weekdays = weekdays + 1;
checkdate = checkdate + 1;
end
end
suspend;
end
There should be other ways to do this in Firebird as well (some of them
better), this is just one way that quickly comes to mind.
HTH,
Set