If a datetime value stored as int in database like 20120707 the following SQL gives us year as 2012, date as 7, and month as 7
Declare @LocalDateID int
set @LocalDateID=20120707
SELECT DATEPART(year, cast(@LocalDateID as char(8))) [Year],
DATEPART(month, cast(@LocalDateID as char(8))) [Month],
DATEPART(day, cast(@LocalDateID as char(8))) [Date]
set @LocalDateID=20120707
SELECT DATEPART(year, cast(@LocalDateID as char(8))) [Year],
DATEPART(month, cast(@LocalDateID as char(8))) [Month],
DATEPART(day, cast(@LocalDateID as char(8))) [Date]
No comments:
Post a Comment