I am working on a query in Sql Server 2008 where I’m migrating the date to a different table.
The source table has a column with DateTime and the destination column has varchar column. I need to convert a DateTime values into varchar.
Source Column has DateTime: 2007-02-13 00:00:00.000
Destination Column has Varchar: mm/dd format
Let me preface with:
THIS IS A TERRIBLE IDEA
If your data represents a date, it needs to be a date datatype!
If you insist on going forward, though, you can do something along the lines of:
SELECT CAST(MONTH(Datefield) as varchar) + '/' + CAST(DAY(Datefield) as varchar)