dongqu4443 2018-06-21 14:43
浏览 659
已采纳

如何通过使用MySql查询中的日期范围来选择数据?

I have a problem related to MySQL query, I use WAMPServer. I have data in database which have range of dates but when I select data for example

select * from CHD WHERE  addtime>='2018-06-15' and addtime<='2018-06-21';

It displays data from '2018-06-15' to '2018-06-20', data of 2018-06-21 are not displayed even if I do

select * from CHD where addtime='2018-06-21'; 

is not working

Please anyone can help me

  • 写回答

1条回答 默认 最新

  • duanmao1919 2018-06-21 14:47
    关注

    This assumes that your column is of type datetime.

    The shorthand version of your date in the filter clause is assumed to be at midnight of the date. Your values that you are attempting to retrieve have times after midnight of that date. You either need to define a timestamp along with the date, or you need to filter by the day after for less than equal to or the day before for greater than equal

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题