Formats the date value according to the format string.

The following specifiers may be used in the format string. The “%” character is required before format specifier characters.

Specifier

Description

%a

Abbreviated weekday name (Sun..Sat)

%b

Abbreviated month name (Jan..Dec)

%c

Month, numeric (0..12)

%D

Day of the month with English suffix (0th, 1st, 2nd, 3rd, …)

%d

Day of the month, numeric (00..31)

%e

Day of the month, numeric (0..31)

%f

Microseconds (000000..999999)

%H

Hour (00..23)

%h

Hour (01..12)

%I

Hour (01..12)

%i

Minutes, numeric (00..59)

%j

Day of year (001..366)

%k

Hour (0..23)

%l

Hour (1..12)

%M

Month name (January..December)

%m

Month, numeric (00..12)

%p

AM or PM

%r

Time, 12-hour (hh:mm:ss followed by AM or PM)

%S

Seconds (00..59)

%s

Seconds (00..59)

%T

Time, 24-hour (hh:mm:ss)

%U

Week (00..53), where Sunday is the first day of the week; WEEK() mode 0

%u

Week (00..53), where Monday is the first day of the week; WEEK() mode 1

%V

Week (01..53), where Sunday is the first day of the week; WEEK() mode 2; used with %X

%v

Week (01..53), where Monday is the first day of the week; WEEK() mode 3; used with %x

%W

Weekday name (Sunday..Saturday)

%w

Day of the week (0=Sunday..6=Saturday)

%X

Year for the week where Sunday is the first day of the week, numeric, four digits; used with %V

%x

Year for the week, where Monday is the first day of the week, numeric, four digits; used with %v

%Y

Year, numeric, four digits

%y

Year, numeric (two digits)

%%

A literal “%” character

%x

x, for any “x” not listed above

Specifier

Description

Ranges for the month and day specifiers begin with zero due to the fact that MySQL permits the storing of incomplete dates such as '2014-00-00'.

The language used for day and month names and abbreviations is controlled by the value of the lc_time_names system variable (Section 10.7, “MySQL Server Locale Support”).

For the %U, %u, %V, and %v specifiers, see the description of the WEEK() function for information about the mode values. The mode affects how week numbering occurs.

DATE_FORMAT() returns a string with a character set and collation given by character_set_connection and collation_connection so that it can return month and weekday names containing non-ASCII characters.

mysql> SELECT DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y');

-> 'Sunday October 2009'

mysql> SELECT DATE_FORMAT('2007-10-04 22:23:00', '%H:%i:%s');

-> '22:23:00'

mysql> SELECT DATE_FORMAT('1900-10-04 22:23:00',

-> '%D %y %a %d %m %b %j');

-> '4th 00 Thu 04 10 Oct 277'

mysql> SELECT DATE_FORMAT('1997-10-04 22:23:00',

-> '%H %k %I %r %T %S %w');

-> '22 22 10 10:23:00 PM 22:23:00 00 6'

mysql> SELECT DATE_FORMAT('1999-01-01', '%X %V');

-> '1998 52'

mysql> SELECT DATE_FORMAT('2006-06-00', '%d');

-> '00'

mysql %u_mysql之DATE_FORMAT相关推荐

  1. mysql 格式化日期 DATE_FORMAT,FROM_UNIXTIME,UNIX_TIME等

    1. DATE_FORMAT() 函数用于以不同的格式显示日期/时间数据. DATE_FORMAT(date,format) 可以使用的格式有: 格式 描述 %a 缩写星期名 %b 缩写月名 %c 月 ...

  2. postgresql兼容MySQL 时间函数date_format

    MySQL DATE_FORMAT() 函数 定义和用法 DATE_FORMAT() 函数用于以不同的格式显示日期/时间数据. 语法 DATE_FORMAT(date,format) date 参数是 ...

  3. MySQL小干货——DATE_FORMAT()函数

    最近项目需要统计某一时间段的的数据,按理说这个需求很常见.可是我硬是找来找去找不出来.真是一分钱逼死英雄汉啊,基础不牢,地动山摇.特写小文一篇以做记载. 其实用到的是MySQL的DATE_FORMAT ...

  4. Mysql 时间格式化 DATE_FORMAT使用

    select * from tableName a where a.time between DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s') and DAT ...

  5. mysql group by date_format( stat_time, '%Y/%m/%d' ) 优化

    mysql从5.7开始支持Generated Column操作,可以看做继承于目标列,但是可以使用函数进行转换. Generated Column有两种类型:stored和virtual. store ...

  6. mysql时间函数 date_format () 、date_sub()、YEERWEEK()、WEEKDAY(),另附本周 上周 本月 上月 本年等日期写法

    一.date_format () .date_sub().YEERWEEK().WEEKDAY() 1) "date_format()":格式化日期格式,"date_fo ...

  7. MySQL时间格式化date_format

    1.定义和用法 DATE_FORMAT(date,format) 2.可用的格式 格式 描述 %a 缩写星期名 %b 缩写月名 %c 月,数值 %D 带有英文前缀的月中的天 %d 月的天,数值(00- ...

  8. mysql %u_mysql 常用

    1.索引 -- 查看某表的所有索引字段 SHOW INDEX FROM table_name; -- 创建某表的某索引字段 CREATE INDEX sku_id ON table_name (sku ...

  9. mysql 数据库时间类型 datetime 数据在页面上显示一串数字, 用函数date_format( )转换格式 ;

    mysql 数据库时间类型 datetime 转换格式 数据库时间字段datetime可以使用date_format( )函数进行时间的转换. 数据库时间字段类型: 数据库查询结果: 没转换前页面显示 ...

最新文章

  1. ssm插入数据时候栈溢出_大话数据结构笔记(4)
  2. 多巴胺如何驱使我们克服复杂情况、逆境、情绪, 让我们掌控周遭的环境的
  3. elk-nginx输出json格式的日志
  4. C# 存储过程 分页
  5. 铺地毯pascal程序
  6. 零基础学Python(第十五章 日期时间datetime、time、Calendar)
  7. php中tables,php显示TABLE数据
  8. .NET 5 开源工作流框架elsa技术研究
  9. dbeaver 连接hbase 数据库
  10. 阿里云刘强:无影云电脑构建云上安全办公室
  11. mysql+php+模板+条目_PHP.MVC的模板标签系统(四)
  12. Linux正则表达式与grep
  13. 物联网核心安全系列——智能家居与数据安全问题
  14. 亚马逊在德国新设AI研发中心,与马克思普朗克系统研究所亲密合作
  15. 用vue手脚架生成的项目直接修改时.vue文件后,保存编译就报一大堆的错,这是咋回事呢?
  16. linux之yum下载rpm包离线安装
  17. 第一个scrum会议
  18. java点名代码滚动_经典案例实现-点名器
  19. nodejs+express中设置登录拦截器
  20. Oracle Study之案例--在RAW上controlfile多元化

热门文章

  1. jquery $.extend() 对象内容合并
  2. linux gcc 宏定义 __GNUC__ __GNUC_MINOR__ 版本区分
  3. wireshark协议解析器原理与插件编写
  4. Buildroot用户指南
  5. f2 自适应_典型的三行二列居中高度自适应布局
  6. 计算机cmd shutdown,cmd里面shutdown命令的原因是什么?什么时候显示的?
  7. 专题2 文件系统结构
  8. 读取list java_java 分批次读取java.util.List 数据
  9. 9型转x型 cobol_【科研模型100例32】A型/X型分子筛
  10. ib课程计算机科学内容,ib课程体系的六大课程