I have the default_report function to fetch last 24 months report
CREATE FUNCTION dbo.default_report
RETURNS TABLE
AS
RETURN
(
SELECT ID,sender,recipient,amount,currency
FROM reports
where submit_date >= dateadd(month,datediff(month,0,getdate())-24,0)
)
I have the custom_report function to fetch the report for specific dates
CREATE FUNCTION dbo.custom_report(@start_date DATE,@end_date DATE)
RETURNS TABLE
AS
RETURN
(
SELECT ID,sender,recipient,amount,currency
FROM reports
where submit_date BETWEEN @start_date AND @end_date
)
The only variable in the above two functions is the where clause, is there a way to combine the above two functions into one and make them work?