ITeye博客

convert和cast

神奇九寨沟 · 2008-11-07 17:31 · sqlserver · Markdown

------------convert日期转成字符串select getdate() select convert(char(8),getdate(),112) select convert(char(8),getdate(),108)

--可以得到日期的部分值, select year(getdate())
select datepart(yy,getdate()) select datepart(mm,getdate())

--这样就可以得到两个年份的相差值 ------字符串转成日期select year(getdate())-datepart(yy,cast('1983-12-31' as datetime))

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。