I have a datetime field that I need to convert into the format DDMONYY (27Aug12). I am currently using convert(nvarchar(30),DateToConvert,13),
but that also spits out the time. How can I easily convert a date to the format I need?
Sql-server – Convert datetime to europe default without time
date formatdatetimesql serversql-server-2008t-sql
Related Question
- Sql-server – Constructing datetime from 2 fields: one integer and a datetime
- Sql-server – SQL Server 2008 Convert String to Datetime question
- SQL Server – Understanding Datetime Formats
- SQL Server 2008 – How to Convert Date and Time
- SQL Server – How to Convert VARCHAR to DATETIME Format
- Sql-server – Convert Varchar To Datetime and Add Seconds
Best Answer
Instead of your hack with replace, why not just cast to the right data type? This doesn't need to be nvarchar and the only reason it contains time is because you included too many characters. You can of course apply your replace here as well (or you could do that at the client).
Results: