Reputation: 75
I am trying to compare the default date in SQL table to getdate() to perform a comparison. What date format should I use for date_expired?
Example:
date_expired = '2015-02-15 00:00:00.000'
I need to compare this to getdate().
When using
date_expired > get_date
the record is not showing up.
When using
'2015-02-15 00:00:00.000' > convert(CHAR(10), getdate(), 101).
The record displays correctly.
Thanks in advance,
Greg
Upvotes: 0
Views: 25
Reputation: 701
I'm not sure what the problem is. When I run the below code, it returns true:
DECLARE @date_expired VARCHAR(MAX) = '2017-02-15 00:00:00.000'
IF @date_expired > GetDate()
SELECT 'true'
ELSE
SELECT 'false'
Upvotes: 1