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 写代码写代码单片机代码写代码写数字按键代码
  • ¥15 django按照距离进行排序
  • ¥15 (标签-微信|关键词-微信公众号)
  • ¥15 matlab中mjs用不了
  • ¥15 Ios抖音直播的时候如何添加自定义图片在直播间!
  • ¥60 riscv-pulpino总线上挂载axi从机
  • ¥15 ssh登录页面的问题
  • ¥50 关于在matlab上对曲柄摇杆机构上一点的运动学仿真
  • ¥15 jetson nano
  • ¥15 :app:debugCompileClasspath'.