mysql求最近一段时间的日期
2018-03-18 本文已影响8人
yahzon
用户密码过期策略
ALTER
USER
‘testuser``'@‘localhost'
PASSWORD
EXPIRE INTERVAL 30
DAY``;
禁用密码过期:
ALTER
USER
'testuser'``@``'localhost'
PASSWORD
EXPIRE NEVER;
基本原理:to_days后方便计算
SELECT TO_DAYS(CURDATE()), id , TO_DAYS(CURDATE())-id, FROM_DAYS (TO_DAYS(CURDATE())-id) FROM seq_help
to_days(CURDATE()) id TO_DAYS(CURDATE())-id from_days (TO_DAYS(CURDATE())-id)
737136 1 737135 2018-03-17
737136 2 737134 2018-03-16
737136 3 737133 2018-03-15
737136 4 737132 2018-03-14
737136 5 737131 2018-03-13
737136 6 737130 2018-03-12
737136 7 737129 2018-03-11
求月初日期
select from_days(to_days(CURDATE())-DAYOFMONTH(CURDATE()-1));
2018-03-01
求日期序列
构造一个表seq_help, 只要id字段,id自增长,填充100行。
SELECT TO_DAYS(CURDATE())-id dd, FROM_DAYS (TO_DAYS(CURDATE())-id) FROM seq_help