zoukankan      html  css  js  c++  java
  • [MySQL]获取当月每一天

    常用使用场景: 统计某个月(某个时间区间)内每一天的数据量 

    1. select date_add(curdate(), interval(cast(help_topic_id as signed integer) - 1) day) day
    2. from mysql.help_topic
    3. where help_topic_id < day(last_day(curdate()))
    4. order by help_topic_id

    延伸用法: 获取一段时间内的每分钟

    1. set @stime = str_to_date('2018-11-07 08:00', '%Y-%m-%d %H:%i');
    2. set @etime = str_to_date('2018-11-07 08:10', '%Y-%m-%d %H:%i');
    3. select date_add(@stime, interval (cast(help_topic_id as signed integer) - 0) minute) minute
    4. from mysql.help_topic
    5. where help_topic_id <= timestampdiff(minute, @stime, @etime)
    6. order by help_topic_id

    顺便贴一下oracle的写法

    1. select trunc(sysdate, 'MM') + rownum - 1 day
    2. from dual
    3. connect by rownum <= to_number(to_char(last_day(sysdate), 'dd'))

    原文地址:https://blog.csdn.net/reeye_/article/details/83655477
  • 相关阅读:
    转换方法
    数组去重
    js常见兼容
    封装cookie
    常用函数封装
    手绘 代码
    Python变量和数据类型,类型转换
    语句块的概念及注释符的使用
    ipython和pip,模块安装方法
    第一个python程序
  • 原文地址:https://www.cnblogs.com/jpfss/p/11131335.html
Copyright © 2011-2022 走看看