Link to home
Start Free TrialLog in
Avatar of jamesdean666
jamesdean666

asked on

Compare two dates in SQL Server T-SQL

I have two dates in an SPROC that I am trying to compare..

What is the easiest way?  This is what I have (PERTINENT PARTS OF SPROC) as I believe the issue is with how I am comparing them:

-- parameter
@target_date date = NULL

--declaraion
DECLARE @original_target_date date = NULL

-- return @original_target_date
SELECT @original_target_date = target_date FROM TxPlus WHERE txplus_id = @txplus_id

the target_date could be updated after this point via update statement.

-- comparison
IF @target_date <> @original_target_date
ASKER CERTIFIED SOLUTION
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jamesdean666
jamesdean666

ASKER

Thanks to both of you.. I kinda used both to come up with this conditional:

 IF (SELECT DATEDIFF(day, @original_target_date, @target_date)) > 0