'这个月 select * from 表名 where convert(char(7),SendDateTime,120)=convert(char(7),getdate(),120)
'上个月 select * from 表名 where convert(char(7),SendDateTime,120)=convert(char(7),dateadd(m,-1,getdate()),120)
'近一个月 select * from 表名 where datediff(d,SendDateTime,getdate())<=30
oracle的 如果是从当前时间到前一个月的这个时候之间的记录总条数:select count(1) from uis_md_stcustom u where firsttime between add_months(sysdate,-1) and sysdate;如果是求当前时间的前面一个月的内的记录总条数:select count(1) from uis_md_stcustom u where to_char(firsttime,'mm') = to_char(add_months(sysdate,-1),'mm');
'这个月
select * from 表名 where convert(char(7),SendDateTime,120)=convert(char(7),getdate(),120)
'上个月
select * from 表名 where convert(char(7),SendDateTime,120)=convert(char(7),dateadd(m,-1,getdate()),120)
'近一个月
select * from 表名 where datediff(d,SendDateTime,getdate())<=30
如果是从当前时间到前一个月的这个时候之间的记录总条数:select count(1)
from uis_md_stcustom u
where firsttime between add_months(sysdate,-1) and sysdate;如果是求当前时间的前面一个月的内的记录总条数:select count(1)
from uis_md_stcustom u
where to_char(firsttime,'mm') = to_char(add_months(sysdate,-1),'mm');