博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql转日期比较_mysql 日期转换 比较
阅读量:6971 次
发布时间:2019-06-27

本文共 1982 字,大约阅读时间需要 6 分钟。

转换为字符串

DATE_FORMAT(post_date,'%Y-%m-%d')

比较

delete from t_agent_file where date(str_to_date(`t_agent_file`.`publish_date`,'%Y-%m-%d')) between '2015-06-01' and '2015-06-18'

DATE_FORMAT 格式

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

%u

Week (00..53), where Monday is the first day of the week

%V

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

%v

Week (01..53), where Monday is the first day of the week; 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

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'

转载地址:http://gqhsl.baihongyu.com/

你可能感兴趣的文章
unstrict模式
查看>>
提高red5性能几个配置。
查看>>
tab键技巧小结
查看>>
数据库管理中文件的使用
查看>>
计算机英语单词汇总
查看>>
TCP、UDP和HTTP详解
查看>>
MYSQL数据库设计规范与原则
查看>>
chrome贴吧插件——源代码
查看>>
201621123048《Java程序设计》第六周学习总结
查看>>
Eclipse快捷键大全(转载)
查看>>
python压缩文件脚本
查看>>
把Catalina的字符串格式转化为日期格式
查看>>
【语法】NSMutableString的用法
查看>>
前端知识点总结(html+css)部分
查看>>
VI/VIM 编辑器
查看>>
C#写爬虫,版本V2.0
查看>>
基于Ubuntu16搭建Hadoop大数据完全分布式环境
查看>>
网络爬虫
查看>>
python-memcached学习笔记
查看>>
转--Java工程师成神之路(2018修订版)
查看>>