1.已知生日,求年龄
TIMESTAMPDIFF(year,birthday,CURDATE()) age
2.根据字段内有无值,判断状态
ISNULL(die_date) status
3.mapper.xml里的date类型与mysql中的日期作比较
<if test="null!=start_diagnosed ">and a.diagnosed >= DATE_FORMAT(#{start_diagnosed}, '%Y-%m-%d') </if>
<if test="null!=end_diagnosed ">and a.diagnosed <= DATE_FORMAT(#{end_diagnosed}, '%Y-%m-%d')</if>
注:if判断中date类型不能与空字符串做对比
4.获取时间
now() sysdate() “yyyy-MM-dd HH-mm-ss”
curdate()“yyyy-MM-dd”
curtime()“HH-mm-ss”