UDF in place of a Macro

Database
Enthusiast

UDF in place of a Macro

Hi

I've the following macro, which calculates the business hours for a time period leaving out the weekends:

CREATE MACRO BHRS (CLOSEDTM TIMESTAMP, STRTDTM TIMESTAMP, BUSHRSPERDAY INTEGER, WKNDHRS INTEGER) AS
(
SELECT CAST (((:CLOSEDTM - :STRTDTM) DAY(4)) * :BUSHRSPERDAY AS INTEGER) + CAST (ABS (EXTRACT(HOUR FROM :STRTDTM) - EXTRACT(HOUR FROM :CLOSEDTM)) AS INTEGER) - CAST(COUNT(CALENDAR_DATE) * :WKNDHRS AS INTEGER)
FROM SYS_CALENDAR.CALENDAR WHERE DAY_OF_WEEK IN (1,7) AND CALENDAR_DATE BETWEEN CAST(:STRTDTM AS DATE) AND CAST(:CLOSEDTM AS DATE);
);

Just wondering, if I can replace the above macro as a UDF, so that this can be called at a row level. Any help & thoughts?

Thanks for your time.