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
Microsoft SQL Server 2008

Avatar of undefined
Last Comment
jamesdean666

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Lowfatspread

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Scott Pletcher

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck