Lutch Lutch - 1 year ago 66
SQL Question

Issue with Date format in SQL

I am currently using SQL Server 2008. I am extracting a column

value from a SQL query where it is returning the date format in

I need the output to be in format

Note that the column
is of datatype
and I cannot change the datatype.

I have tried below but the getting the needed output

H.F254 AS Original_Date, --> 8/17/2017
CONVERT(VARCHAR(10), H.F254, 111) AS eg1, --> 8/17/2017
REPLACE(CONVERT(VARCHAR(10), H.F254, 103), '/', '') AS eg2 -->8172017
CONVERT(VARCHAR(9), H.F254, 112) AS eg3 --> 8/17/2017

I have also checked the following Date Format but its not working

Answer Source

I think you have to convert it to a date first!

select convert(varchar(10),cast(H.F254 as date),112)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download