leetcode-1853. 转换日期格式
作者:互联网
1853. 转换日期格式 https://leetcode.cn/problems/convert-date-format/ SQL: SELECT concat(dayname(day), ', ', monthname(day), ' ', day(day), ', ', year(day)) AS day FROM Days 结果
{"headers": ["day"], "values": [["Tuesday, April 12, 2022"], ["Monday, August 9, 2021"], ["Friday, June 26, 2020"]]} 使用到的几个知识点 mysql 月份转英文 monthname() 示例:MySQL MONTHNAME() from numbers mysql 星期几 使用dayofweek()函数,结合 case when
SELECT
CASE
DATE_FORMAT(NOW(),'%w')
WHEN 1 THEN '星期一'
WHEN 2 THEN '星期二'
WHEN 3 THEN '星期3'
WHEN 4 THEN '星期4'
WHEN 5 THEN '星期五'
WHEN 6 THEN '星期6'
WHEN 7 THEN '星期日'
END
as week
mysql> select dayname('20200905');
+---------------------+
| dayname('20200905') |
+---------------------+
| Saturday |
+---------------------+
标签:星期,+---------------------+,dayname,1853,WHEN,day,mysql,格式,leetcode 来源: https://www.cnblogs.com/shoshana-kong/p/16529735.html