7

I have a table with datekey column values(20120728,20120728...) in format of yyyymmdd as int type, I need to make them into date format of mm/dd/yyyy while writing select statement.

Cœur
  • 37,241
  • 25
  • 195
  • 267
user2963607
  • 71
  • 1
  • 1
  • 2

2 Answers2

19
DECLARE @date int;
SET @date = 20131107

SELECT CONVERT(date, CONVERT(varchar(8), @date), 112)
vhadalgi
  • 7,027
  • 6
  • 38
  • 67
10

Please Try This

DECLARE @date int;
SET @date = 20120728    
SELECT CONVERT(varchar(20), CONVERT(date, CONVERT(varchar(8), @date), 112),110)as datetime
code save
  • 1,054
  • 1
  • 9
  • 15
  • hi, this one is giving ans with - separated date i need adte in the format separated by '/', thanks for your reply, wil post my ans, it wont allow my reply to my question now – user2963607 Nov 07 '13 at 12:59
  • thanks that result can be separated by '/' ; you can place 103 insteed of 110 – code save Nov 07 '13 at 13:40