问题
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.
回答1:
DECLARE @date int;
SET @date = 20131107
SELECT CONVERT(date, CONVERT(varchar(8), @date), 112)
回答2:
Please Try This
DECLARE @date int;
SET @date = 20120728
SELECT CONVERT(varchar(20), CONVERT(date, CONVERT(varchar(8), @date), 112),110)as datetime
来源:https://stackoverflow.com/questions/19829818/sql-date-format-conversion-from-intyyyymmdd-type-to-datemm-dd-yyyy