Created
February 12, 2013 17:03
-
-
Save MRdNk/4771369 to your computer and use it in GitHub Desktop.
Checks if two DateTimes are the same Date, ignoring time.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GO | |
/****** Object: UserDefinedFunction [dbo].[fnIsSameDate] Script Date: 02/12/2013 17:02:41 ******/ | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
-- ============================================= | |
-- Author: Duncan Angus Wilkie | |
-- Create date: 12/02/2013 | |
-- Description: Do datetime (DATE only) match? | |
-- ============================================= | |
CREATE FUNCTION [dbo].[fnIsSameDate] | |
( | |
@Date1 datetime, | |
@Date2 datetime | |
) | |
RETURNS bit | |
AS | |
BEGIN | |
IF (DATEADD(dd, 0,DATEDIFF(dd, 0, @Date1)) = DATEADD(dd, 0,DATEDIFF(dd, 0, @Date2))) | |
RETURN 1; | |
RETURN 0; | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment