Skip to content Skip to sidebar Skip to footer

Sql Date Format Conversion From Int(yyyymmdd) Type To Date(mm/dd/yyyy)

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

Solution 1:

DECLARE @date int;
SET @date = 20131107

SELECT CONVERT(date, CONVERT(varchar(8), @date), 112)

Solution 2:

Please Try This

DECLARE @date int;
SET @date = 20120728    
SELECT CONVERT(varchar(20), CONVERT(date, CONVERT(varchar(8), @date), 112),110)as datetime

Post a Comment for "Sql Date Format Conversion From Int(yyyymmdd) Type To Date(mm/dd/yyyy)"