How To Sort Date When Date Is Formatted

  • Hi all,

    I have a problem. The problem is that I want to sort dates in descending order, but the date needs to be formatted.

    The issue is that when I sort it after being formatted it is sorted on a string or varchar basis, which does not sort correctly according to the dates.

    Can anyone help me?

    Thanks in advance

  • Sort on the unformatted date instead of the formatted date, something like the below

    SELECT

    CONVERT(VARCHAR,DateColumn,103) AS FormattedDate,

    DateColumn AS Non-FormattedDate

    FROM

    SomeTable

    ORDER BY

    DateColumn DESC

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply