I have a Date field in a table that is an int. The value looks like this: 20130618 I want to be able to convert that to an actual date like 06/18/2013 so I can do date calculations on it. How do I convert that field?
Asked
Active
Viewed 72 times
0
-
1Change the table. Or what do you expect to do when you encounter a value like `20130299`? The design is broken. – Damien_The_Unbeliever Jun 18 '13 at 17:29
1 Answers
1
select convert(date, left(20130618, 8), 101)
or
select convert(date, cast(20130618 as char(8)), 101)

t-clausen.dk
- 43,517
- 12
- 59
- 92