I have date format like 20151030 I want to change it 30/10/2015 12:23:43 PM . Can anyone please advise on this.
Asked
Active
Viewed 171 times
-1
-
Fast response will be much appreciated. I AM STUCK AT THIS. – PUSHP Jan 27 '16 at 04:21
-
Are you talking about query results? – PM 77-1 Jan 27 '16 at 04:24
-
Yes..i want to change date format to date time format in sql – PUSHP Jan 27 '16 at 04:30
-
What is the data type of your field? – PM 77-1 Jan 27 '16 at 04:37
-
It is simple number like 20151030 – PUSHP Jan 27 '16 at 04:42
-
How is it stored in the database? As **what**? – PM 77-1 Jan 27 '16 at 04:43
-
12:23:43 **PM**? If it's past 12, it's PM by definition. AM/PM is only added if you want hours < 12. – TT. Jan 27 '16 at 07:17
1 Answers
0
You can use the following query
select CONVERT(varchar(25), CONVERT(datetime, CAST(20151030 AS CHAR(10)), 113), 103)
The output would be 30/10/2015
You can also visit This URL For a list of date formatting specifications.
This SO Post discusses on the similar lines about date formatting.