birthday datetime NOT NULL,
birthday timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
用
select date_format(from_days(to_days(now())-to_days(birthday)), '%Y'),date_format(from_days(to_days(now())-to_days(birthday)), '%m')把月也显示出来如果年是0 就显示月
或者
select if(to_days(now()) = to_days(birthday),concat(date_format(from_days(to_days(now())-to_days(birthday)),'年') ,concat(date_format(from_days(to_days(now())-to_days(birthday)),'月')) as a from ......
直接得出
alter table `a` add `birthday` datatypedatatype , 你这里要写成具体的数据类型~mysql是没有"datatype"数据类型的~
建议定义为 datetime 或者int(存储unix时间戳~)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)