在pb9中由于需要,现需要自定义一个专门计算年龄的外部函数供需要的地方调用,出生日期和当前日期作为该自定义函数的参数,输出有三个参数是xx岁,xx月,xx天。急求有过类似编程经验或者手里正好有资源的前辈们提供帮助!
另外如果有通过身份证号得出出生日期的资源或者方式也可以拿出来分享下!
------解决方案--------------------
应该对你有用。
if ( dcsrq>today() or daysafter (dcsrq ,today() ) >365*180 ,'年龄错误',(if (daysafter (dcsrq,today() ) >365, (if (daysafter (dcsrq,today() ) <365*14, (string (int (daysafter (dcsrq,today()) /365) ) +'岁'+
if(mod (int (daysafter (dcsrq,today() ) /30.5) ,12) = 0,'',
string (mod (int (daysafter (dcsrq,today()) /30.5) ,12) ) +'个月') ),
string (int (daysafter (dcsrq,today()) /365) ) +'岁') ) ,
if(mod (int (daysafter (dcsrq,today()) /30.5) ,12) = 0,'',
string (int(daysafter (dcsrq,today())/30.5 ))+'个月' )
+
if(daysafter (dcsrq,today())>31,
if(int(mod ( daysafter (dcsrq,today() ),30.5) )=0,'',string (int(mod ( daysafter (dcsrq,today() ),30.5 )) +'天') ),
string (int(1+mod ( daysafter (dcsrq,today() ),30.5 )) +'天')
)) ) )
------解决方案--------------------
建立全局结构体 us_age
- C/C++ code
global type us_age from structure integer years integer months integer daysend type