I have a problem: I have a datetime and I need the date to specific format
So I just casted datetime to time
SELECT CAST (GETDATE() AS DATE) -- result (2011-06-08)
and for formatting I use convert
SELECT CONVERT(DATE, CAST (GETDATE() AS DATE), 105) --result (2011-06-08)
105 format (dd-mm-yy)
but, the result of both is same,
CONVERT is not working for 105 formatting,
Any ideas?
thanks
To get the results you’re looking for you need to convert the DATE to a VARCHAR like this:
If you cast to a DATE, you will always get the full DATE.
You can truncate the date by re-casting to the DATE type.