mysql判断范围0到10 11到20_SQL 如何查询日期在一定范围内的数据

展开全部

select * from 表32313133353236313431303231363533e78988e69d8331333365666163 where 日期字段>='开始日期' and 日期字段<='截止日期'  and convert(char(8),日期字段,108)>='开始时间' and convert(char(8),日期字段,108)<='截止时间'。

SELECT * FROM 表明 WHERE 日期字段名 BETWEEN '20130101' AND '20130130'。

例如:

select * from tb1 where dDate>='2010-11-05' and dDate<='2010-11-15'

and convert(char(8),dDate,108)>='8:00:00' and convert(char(8),dDate,108)<='9:00:00'.

select * from table1 where year(d)=2010 and month(d)=7 and day(d) between 1 and 31

and (Datepart(hour,d)>=22 or Datepart(hour,d)<6)

d1fef9d4a8727a28f3ff06bc25d9113c.png

扩展资料:

SQL查询日期:

今天的所有数据:select * from 表名 where DateDiff(dd,datetime类型字段,getdate())=0

昨天的所有数据:select * from 表名 where DateDiff(dd,datetime类型字段,getdate())=1

7天内的所有数据:select * from 表名 where DateDiff(dd,datetime类型字段,getdate())<=7

30天内的所有数据:select * from 表名 where DateDiff(dd,datetime类型字段,getdate())<=30

本月的所有数据:select * from 表名 where DateDiff(mm,datetime类型字段,getdate())=0

本年的所有数据:select * from 表名 where DateDiff(yy,datetime类型字段,getdate())=0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值