I am using the following way to compare two dates:
if CONVERT(varchar(20), @ScheduleDate, 101) >= CONVERT(varchar(20), @CurrentDateTime, 101)
This is working fine for the current year, but when the comes in yearly like one date is 12/31/2012 and 1/1/2013 then its not working.
Please help me how can I resolve this.
why do you comparing strings?
you can compare dates
but if your date contains time, I usually do
112 datetime format is YYYYMMDD so it’s good for compare dates