zoukankan      html  css  js  c++  java
  • MySQL常用函数【随时更新】

    一  日期函数

    1. 取本月1号

    mysql> select concat(date_format(now(), '%Y-%m'),'-01');
    +-------------------------------------------+
    | concat(date_format(now(), '%Y-%m'),'-01') |
    +-------------------------------------------+
    | 2020-09-01                                |
    +-------------------------------------------+
    1 row in set (0.02 sec)
    
    mysql> select concat(date_format(now(), '%Y%m'),'01');
    +-----------------------------------------+
    | concat(date_format(now(), '%Y%m'),'01') |
    +-----------------------------------------+
    | 20200901                                |
    +-----------------------------------------+
    1 row in set (0.02 sec)

    2. 取本周始末

    mysql> select subdate(now(), date_format(now(),'%w')-1) '本周一';
    +---------------------+
    | 本周一              |
    +---------------------+
    | 2020-09-14 17:10:03 |
    +---------------------+
    1 row in set (0.04 sec)
    
    mysql> select subdate(now(), date_format(now(),'%w')-7) '本周日';
    +---------------------+
    | 本周日              |
    +---------------------+
    | 2020-09-20 17:10:12 |
    +---------------------+
    1 row in set (0.05 sec)

  • 相关阅读:
    重载函规则
    lambd
    内联函数
    c和c++中的枚举和 区别
    关于于c++中的类型转换
    作用域解析运算符
    day01
    二级指针输入特性
    二级指针的 数出特性
    influence maximization 第二弹
  • 原文地址:https://www.cnblogs.com/LUA123/p/13686210.html
Copyright © 2011-2022 走看看