Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (55.6k points)

When I am using order by date, the result set is sorted by date but not including the year. Can anyone tell me how to use the order by date column?

1 Answer

0 votes
by (119k points)

The reason may be because the DateTime is varchar datatype but not in date format. So, try the following SQL query to order the rows by date column:

SELECT *

FROM Table_name

            CONVERT (DateTime, date_column, 101) ASC|DESC

If you want to learn SQL from Industry experts then take up this SQL Training course by Intellipaat that provides Instructor-led training, hands-on experience, and certification.

Related questions

0 votes
1 answer
asked May 5, 2020 in SQL by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked May 4, 2020 in SQL by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked Apr 28, 2020 in SQL by Sudhir_1997 (55.6k points)
0 votes
1 answer

Browse Categories

...