Subject | Re: [firebird-support] working days between two dates |
---|---|
Author | Tomasz Tyrakowski |
Post date | 2015-01-16T20:05:36Z |
If you mean week days only, probably you can come up with a clever
stored procedure or UDF (shouldn't be that hard), but if you have to
take various bank holidays into account, most of which are
state-specific or even mobile (e.g. easter), a general, elegant solution
doesn't come to mind.
However, I can share with you a dirty hack I did years ago and it still
works like a charm: I pre-generated all holidays (including mobile ones,
like easter - consult wikipedia how to calculate easter) for a couple of
hundred years in advance and stored them in a table. Then I just had to
exclude the dates from this table from any date spans I wanted to be
holiday-free. The disadvantage of this solution is that when your
government passes a bill constituting a new bank holiday, you have to
update this table in all your production databases, or you're toast. On
the other hand, you'd need to update the procedure/UDF/whatever anyway,
so it's not that big a disadvangage after all.
Please post a note to the list if you find a better solution.
regards
Tomasz
stored procedure or UDF (shouldn't be that hard), but if you have to
take various bank holidays into account, most of which are
state-specific or even mobile (e.g. easter), a general, elegant solution
doesn't come to mind.
However, I can share with you a dirty hack I did years ago and it still
works like a charm: I pre-generated all holidays (including mobile ones,
like easter - consult wikipedia how to calculate easter) for a couple of
hundred years in advance and stored them in a table. Then I just had to
exclude the dates from this table from any date spans I wanted to be
holiday-free. The disadvantage of this solution is that when your
government passes a bill constituting a new bank holiday, you have to
update this table in all your production databases, or you're toast. On
the other hand, you'd need to update the procedure/UDF/whatever anyway,
so it's not that big a disadvangage after all.
Please post a note to the list if you find a better solution.
regards
Tomasz
On 2015-01-16 o 18:51, shg_sistemas@... [firebird-support] wrote:
> Hello, using FB 2.5 is there an easy way to get the workings days between to dates? Or should I do an UDF for that?
>
>
> Thanks!!
>
--
__--==============================--__
__--== Tomasz Tyrakowski ==--__
__--== SOL-SYSTEM ==--__
__--== http://www.sol-system.pl ==--__
__--==============================--__