Every time i run this function getting an error not sure what i am doing wrong.
Using Pervasive 9.71
CREATE FUNCTION WorkDays
(IN :StartDate DATETIME, IN :EndDate DATETIME)
RETURNS DATETIME;
BEGIN
RETURN
(SELECT
(DATEDIFF(day,:StartDate,:EndDate)+1)
-(DATEDIFF(week,:StartDate,:EndDate)*1)
-(CASE WHEN DATENAME(weekday,:StartDate) = 'Sunday'
THEN 1
ELSE 0
END)
-(CASE WHEN DATENAME(weekday,:EndDate) = 'Sunday'
THEN 1
ELSE 0
END)
-(CASE WHEN DATEDIFF(day, :StartDate, :EndDate)< 7
THEN 1
ELSE 0
END));
END
#
Using Pervasive 9.71
CREATE FUNCTION WorkDays
(IN :StartDate DATETIME, IN :EndDate DATETIME)
RETURNS DATETIME;
BEGIN
RETURN
(SELECT
(DATEDIFF(day,:StartDate,:EndDate)+1)
-(DATEDIFF(week,:StartDate,:EndDate)*1)
-(CASE WHEN DATENAME(weekday,:StartDate) = 'Sunday'
THEN 1
ELSE 0
END)
-(CASE WHEN DATENAME(weekday,:EndDate) = 'Sunday'
THEN 1
ELSE 0
END)
-(CASE WHEN DATEDIFF(day, :StartDate, :EndDate)< 7
THEN 1
ELSE 0
END));
END
#