Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个带有日期键列值(20120728,20120728...)的表格,格式yyyymmdd为 int 类型,我需要mm/dd/yyyy在编写 select 语句时将它们变成日期格式。
yyyymmdd
mm/dd/yyyy
DECLARE @date int; SET @date = 20131107 SELECT CONVERT(date, CONVERT(varchar(8), @date), 112)
请试试这个
DECLARE @date int; SET @date = 20120728 SELECT CONVERT(varchar(20), CONVERT(date, CONVERT(varchar(8), @date), 112),110)as datetime