1

Say I am trying to sort through and I want to see the dates 10/22/2020, 10/23/2020, 10/24/2020, and/or 5/5/2020. How could I do this? When I run with the following code it will not work.

AND appointmentsTable.scheduledDate = @startDate 
AND appointmentsTable.scheduledDate = @date2
AND appointmentsTable.scheduledDate = @date3
AND appointmentsTable.scheduledDate = @endDate

Screenshot of query I currently have

  • check this https://stackoverflow.com/questions/119730/how-do-i-sort-a-varchar-column-in-sql-server-that-contains-numbers – Amirhossein Oct 21 '20 at 22:04

1 Answers1

2

You would convert to a date:

order by convert(date, appointmentdate, 101)

But you should fix your data model so dates are stored as dates.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786