doudao5287 2018-06-04 09:14
浏览 38

显示特定周期间创建的sql记录

I have tons of records that are in my database table leadactivity basically I need to display all the records that were created in the first week of the current month, then also another query to display records in the second week, same for third week and then finally the fourth week of the current month.

I have a column called created_date which onupdate puts in the current timestamp

What is the best way to achieve this?

  • 写回答

1条回答 默认 最新

  • dongxiaoxing3058 2018-06-04 11:17
    关注

    You can use date functions for this:

    select la.*
    from leadactivity la
    where day(la.created_date) between 1 and 7 and
          created_date >= curdate() + (1 - day(curdate())) day;
    

    The above assumes MySQL syntax. Most databases have similar functionality, although the specific functions may differ.

    评论

报告相同问题?

悬赏问题

  • ¥20 dify的代码解释器工具和代码执行节点有什么区别?代码解释器工具怎么用?
  • ¥100 springboot2.7.x 整合 sharding 的问题
  • ¥15 如何通过命令行操作统信360安全浏览器?
  • ¥15 upload-labs-master第三关
  • ¥15 关于LT3758反激式负压电源,功率三极管烧毁的问题
  • ¥20 aruba ap305 CAP转IAP
  • ¥20 rockchip rk3588 ffmedia运行异常
  • ¥30 如何用 Java 简单系统设计?(相关搜索:服务器|面向对象设计|随机数)
  • ¥15 鸿蒙开发(关键词-开发环境)
  • ¥15 错误使用 mex Embedding metadata in the MEX file failed.