Question

I have this small query

SELECT 
    MAX(myDate) AS DateToUser
FROM 
    blaTable

I'm getting this result "2011-05-23 15:18:01.223"

how can I get the result like 05/23/2011 "mm/dd/yyyy" format?

Was it helpful?

Solution 2

SELECT
    convert(varchar, MAX(myDate), 101) AS DateToUser
FROM 
    blaTable

For more Date Format Parameters: Click Here

OTHER TIPS

Try this

FIDDLE DEMO

SELECT 
   convert(varchar,MAX(myDate),101) AS DateToUser
FROM blaTable

CONVERT

If you are using SQL SERVER 2012 then Simple use FORMAT

SELECT 
    FORMAT(MAX(myDate),'MM/dd/yyyy') AS DateToUser
FROM blaTable

FORMAT

SELECT 
    CONVERT(VARCHAR(20),MAX(myDate),101) AS DateToUser
FROM 
    blaTable

For more information on Sql server datetime formats have a look here

SQL SERVER FORMATS

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top