27,580
社区成员
发帖
与我相关
我的任务
分享
select * from tb where CreateDate=CONVERT(varchar(8) ,getdate(), 112 )
select * from tb where datediff(dd,CreateDate,getdate())=0 --今天
select * from tb where datediff(dd,CreateDate,getdate())=1 --昨天
依次类推
select * from tb where datediff(dd,createdate,getdate())=0
select * from tb where datediff(dd,createdate,getdate())=1
select * from tb where datediff(dd,createdate,getdate())=-1
select * from tb where CreateDate=CONVERT(varchar(8) ,getdate(), 112 )
--日期转换参数
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
20040912110608
select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12
select CONVERT(varchar(12) , getdate(), 112 )
20040912
select CONVERT(varchar(12) , getdate(), 102 )
2004.09.12
select CONVERT(varchar(12) , getdate(), 108 )
11:06:08