我需要找到DateDiff
nvarchar
对getdate
值的方法:
create table dbo.DateChk
([DateString] [nvarchar](24) NULL)
insert into dbo.DateChk (DateString) values ('20130112'),('20131121'), ('20130924'),('20130515')
select getdate(), DateString
---, getdate()- DateString as DateDiff
from dbo.DateChk
答案 0 :(得分:1)
只需使用DATEDIFF
功能:
select getdate(), DateString
---, getdate()- DateString as DateDiff
, DATEDIFF(DAY, DateString, getdate())
from dbo.DateChk