F_SUBPERIOD
<< F_ADDPERIOD | IBExpert UDF Functions | F_AGEINYEARS >>
F_SUBPERIOD
- function from adhoc
- Compatible with UTF-8
- Input VARCHAR(254) period 1 in pattern [d]:h:m:s, VARCHAR(254) period 2 in pattern [d]:h:m:s
- Output VARCHAR(254) period 2 subtracted from period 1
Periods could be entered with 2- or 1 digits interval (dd:hh:mm:ss or d:h:m:s). Negative periods starts with a "-" in front. Periods with pattern days:hours:minutes:seconds (4 intervalls) or hours:minutes:seconds (3 intervalls) are allowed. The output of periods with less than 3 intervalls or containing other characters is <null> or empty string. For input also f.e. '0:26:0:0' instead of '1:2:0:0' alllowed for 26 hours. The output is allways in pattern days:hours:minutes:seconds (4 * 2 digit intervalls). If second input period is greater than first, the output is negativ ("-" in front).
Example
select '00:00:54:50' as ISCORRECT, F_SUBPERIOD('0:1:10:0', '0:0:15:10') from RDB$DATABASE union select '-00:00:54:50' as ISCORRECT, F_SUBPERIOD('0:0:15:10', '0:1:10:0') from RDB$DATABASE union select null as ISCORRECT, F_SUBPERIOD(null, null) from RDB$DATABASE;
Expected results:
ISCORRECT ============ ======================================================= <null> <null> -00:00:54:50 -00:00:54:50 00:00:54:50 00:00:54:50
back to top of page
<< F_ADDPERIOD | IBExpert UDF Functions | F_AGEINYEARS >>