CREATE FUNCTION dbo.f_SKX_IsDataCross ( @fromDate DATETIME , @toDate DATETIME , @startDate DATETIME , @endDate DATETIME ) RETURNS INT AS BEGIN DECLARE @ret INT IF ( DATEDIFF(DAY, @fromDate, @endDate) >= 0 AND DATEDIFF(DAY, @endDate, @toDate) >= 0 ) SET @ret = 1 IF ( DATEDIFF(DAY, @startDate, @toDate) >= 0 AND DATEDIFF(DAY, @toDate, @endDate) >= 0 ) SET @ret = 1 IF ( @ret IS NULL ) SET @ret = 0 RETURN @ret END