Get max date from a varchar in SQL query!

I need to get the max date from  a varchar of a table in format 103  dd/mm/YYYY

whats the query in sql
please you experts!
ErnestoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pcelbaCommented:
SELECT MAX(CONVERT(datetime, YourVarCharColumn, 103)) AS maxDate
  FROM YourTable

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Russ SuterSenior Software DeveloperCommented:
SELECT
  CONVERT(DATETIME, [columnName], 103) as MaxDate
FROM
  [tableName]
WHERE
  [columnName] IN
  (
  SELECT
    MAX([columnName])
  FROM
    [tableName]
  )

Open in new window

Note, if two or more rows in the table share the exact same DATETIME value you will get more than one row using this method.
pcelbaCommented:
Maybe I am missing something but MAX() from varchar column containing the date in given format does not calculate the maximum date value.
Jim HornMicrosoft SQL Server Data DudeCommented:
>I need to get the max date from  a varchar of a table in format 103
(1) Please give us a data mockup of what these varchar's are, as things can get ugly real quick.
(2) Just to state the obvious dates should be stored in date column data types and not as varchar's, as that invites errors to occur when data is entered in a non-date format, and then a later query attempts to convert the value to a date and then fails.
ErnestoAuthor Commented:
Thank you guys !
regards
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.