функции, которая реализует описанный алгоритм:
CREATE FUNCTION CheckDates(@inputString NVARCHAR(MAX))
RETURNS BIT
AS
BEGIN
DECLARE @dateRegex NVARCHAR(MAX) = '[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}'
DECLARE @dateCount INT = (SELECT COUNT(*) FROM dbo.fn_SplitString(@inputString, N' ') WHERE PATINDEX(@dateRegex, value) > 0)
IF @dateCount < 4
RETURN 0
DECLARE @datePairs TABLE (date1 DATE, date2 DATE)
INSERT INTO @datePairs
SELECT d1.dateValue, d2.dateValue
FROM (SELECT CAST(value AS DATE) AS dateValue FROM dbo.fn_SplitString(@inputString, N' ') WHERE PATINDEX(@dateRegex, value) > 0) d1
CROSS JOIN (SELECT CAST(value AS DATE) AS dateValue FROM dbo.fn_SplitString(@inputString, N' ') WHERE PATINDEX(@dateRegex, value) > 0) d2
WHERE d1.dateValue < d2.dateValue
IF EXISTS (SELECT 1 FROM @datePairs WHERE DATEDIFF(DAY, date1, date2) > 21)
RETURN 0
RETURN 1
END