年月日 时分秒 :Select Convert(Char(20),GetDate(),120)
年月日:Select Convert(Char(10),GetDate(),120)
年 /月 :Select Convert(Char(7),GetDate(),111) 结果:2019/06
年 :select CONVERT(varchar(4),GETDATE(),23) 2019年
博客展示了SQL中不同日期格式的转换示例,包括年月日时分秒、年月日、年月、年等格式,通过Select Convert函数结合不同参数实现转换,如Select Convert(Char(20),GetDate(),120)可获取年月日时分秒格式。
年月日 时分秒 :Select Convert(Char(20),GetDate(),120)
年月日:Select Convert(Char(10),GetDate(),120)
年 /月 :Select Convert(Char(7),GetDate(),111) 结果:2019/06
年 :select CONVERT(varchar(4),GETDATE(),23) 2019年
524
3610

被折叠的 条评论
为什么被折叠?