sps List中根据利用Today和birth字段,计算用户年龄
- 再list中添加Today字段,类型为日期型 ;format:date only ;Default value:Today's date
- 添加一个birth字段,类型为日期型
- 添加一个calculated字段,
=YEAR(Today)-YEAR(birth)-IF(OR(MONTH(Today)<MONTH(birth),AND(MONTH(Today)=MONTH(birth),DAY(Today)<DAY(birth))),1,0)&" years, "&MONTH(Today)-MONTH(birth)+IF(AND(MONTH(Today)<=MONTH(birth),DAY(Today)<DAY(birth)),11,IF(AND(MONTH(Today)<MONTH(birth),DAY(Today)>=DAY(birth)),12,IF(AND(MONTH(Today)>MONTH(birth),DAY(Today)<DAY(birth)),-1)))&" months,
"&Today-DATE(YEAR(Today),MONTH(Today)-IF(DAY(Today)<DAY(birth),1,0),DAY(birth))&" days"
摘自Mark Kruger的blog