检查年龄是否周岁

日期时间问题 | 2015-02-17 21:07:47 | 1246次阅读 | 2评
Year(Date())-Year(DDate)+IIF(MONTH(Date())-MONTH(DDate)>0,0,IIF(Day(Date())-Day(DDate)>=0,0,-1))

改为

Year(Date())-Year(DDate)+IIF(MONTH(Date())-MONTH(DDate)<0,-1,IIF(Day(Date())-Day(DDate)>=0,0,-1))
博友评论,共2条
Avatar
1楼: antony521 发表于 2015-07-29 15:19   回复
这个有错误,如1974/11/9应为40周岁,现结果41.
Avatar
2楼: sdta 发表于 2015-08-13 12:40   回复
谢谢回复,改为如下代码就可以了

Year(Date())-Year(DDate)+IIF(MONTH(Date())-MONTH(DDate)<0,-1,IIF(Day(Date())-Day(DDate)>=0,0,-1))
浏览172849次
最新评论