检查年龄是否周岁

日期时间问题 | 2015-02-17 21:07:47 | 1137次阅读 | 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))
浏览160986次