F_AGEINWORKINGDAYS

<< F_AGEINDAYSN | IBExpert UDF Functions | F_AGEINHOURS >>

F_AGEINWORKINGDAYS

 
  • function from adhoc
  • Compatible with UTF-8
  • Input TIMESTAMP (older) date optionally time 1, TIMESTAMP (newer) date optionally time 2, INTEGER weekday don't calculate
  • Output INTEGER difference in (integer) days between timestamp 1 and timestamp 2 less of weekday/s from param 3

weekday: Monday = 1, Thuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7 If 1st date is newer than 2nd date, the result is negative. Any order of indexes for weekdays. Only allowed indexes are calculated.

Example

 select 4 as ISCORRECT, F_AGEINWORKINGDAYS('12.12.2018', '17.12.2018', 7)
 from RDB$DATABASE
 union
 select 3 as ISCORRECT, F_AGEINWORKINGDAYS('12.12.2018', '17.12.2018', 67)
 from RDB$DATABASE
 union
 select -3 as ISCORRECT, F_AGEINWORKINGDAYS('17.12.2018', '12.12.2018', 67)
 from RDB$DATABASE
 union
 select 2 as ISCORRECT, F_AGEINWORKINGDAYS('12.12.2018', '17.12.2018', 467)
 from RDB$DATABASE
 union
 select 5 as ISCORRECT, F_AGEINWORKINGDAYS('12.12.2018', '17.12.2018', 9)
 from RDB$DATABASE
 union
 select 5 as ISCORRECT, F_AGEINWORKINGDAYS('12.12.2018', '17.12.2018', 890)
 from RDB$DATABASE
 union
 select 0 as ISCORRECT, F_AGEINWORKINGDAYS('09.01.2018', '09.01.2018', 67)
 from RDB$DATABASE
 union
 select null as ISCORRECT, F_AGEINWORKINGDAYS(null, null, null)
 from RDB$DATABASE;

Expected results:

    ISCORRECT
 ============ ============
       <null>       <null>
           -3           -3
            0            0
            2            2
            3            3
            4            4
            5            5

back to top of page
<< F_AGEINDAYSN | IBExpert UDF Functions | F_AGEINHOURS >>