需求描述:

  mysql中,如果要查看某个日期是星期几,可以用date_format函数实现,在此记录下.

操作过程:

1.通过date_format函数查看某个日期是星期几

mysql> select date_format('2018-06-26','%W');  #%W(大写W),查看出来的是日期所在的星期,英文的全写Tuesday
+--------------------------------+
| date_format('2018-06-26','%W') |
+--------------------------------+
| Tuesday                        |
+--------------------------------+
1 row in set (0.00 sec)

mysql> select date_format('2018-06-26','%a');  #%a返回的是日期所在的星期英文的简写,Tue,注意:Abbreviated=a,简短的
+--------------------------------+
| date_format('2018-06-26','%a') |
+--------------------------------+
| Tue                            |
+--------------------------------+
1 row in set (0.00 sec)

备注:其中的%a,%W都是格式字符串,date_format函数根据格式字符串将日期值进行格式化输出.

 

文档创建时间:2018年6月26日12:35:30

相关文章:

  • 2021-11-07
  • 2021-10-17
  • 2021-12-28
  • 2021-08-07
  • 2021-12-28
  • 2021-12-03
  • 2021-12-04
  • 2021-11-19
猜你喜欢
  • 2021-12-28
  • 2021-10-19
  • 2021-11-01
  • 2021-11-01
  • 2021-10-06
  • 2022-01-02
  • 2021-11-01
  • 2021-12-26
相关资源
相似解决方案