Using CONVERT with MIN or MAX in SQL SELECT

I need to use CONVERT together with MAX and MIN in SQL SELECT, but the code below is not working. Is it possible to use these functions together or something is incorrect in my code ?

SELECT id, user CONVERT( date, max(registration_date) )
FROM users
WHERE user LIKE 'abc'
GROUP BY user
30 Sep 2020 at 04:19 PM
0pnshow more
StorStor
Hi,

To convert the date according to your needs, you have to include CONVERT into MAX function. The using of these functions together should look like:


SELECT id, user, MAX( CONVERT( date, registration_date) )
FROM users
WHERE user LIKE 'abc'
GROUP BY user

11 Oct 2020 at 11:36 AM
0pnshow more
TimTim
Share on FacebookShare on TwitterShare on LinkedInSend email
Follow us on Facebook & Twitter
2022 AnswerTabsTermsContact us