I would like to convert int to date format, The values are in this format ddmmyy
280118
select cast( '280118' as date)
this results in 2028-01-18
,
I have found way from Stack using substring
select convert(date, SUBSTRING('280118',1,2)+'/'+
SUBSTRING('280118',3,2)+'/'+SUBSTRING('280118',5,2),3)
Expected Result 2018-01-28
.
Is there any simple alternate way to acheive this in SQL server 2016
, It is also quite useful if you can suggest from version 2012
onwards.
I have seen posts as this has been answered already many times, i would like to see any simpler ways of answering this.
Appreciate your comments, suggestions