计算年龄函数(精确到天数)
以下是我写的函数体:
var
vAges : string;//返回结果
prmt_Ages : string ;//参数
begin
prmt_Ages := '2005-02-1';
if YearsBetween(now,strToDate(prmt_Ages))=0 then
begin
if MonthsBetween(now,strToDate(prmt_Ages))=0 then
vAges := IntToStr(DaysBetween(now-2,strToDate(prmt_Ages)))+ '天'
else begin
vAges :=IntToStr(MonthsBetween(now,strToDate(prmt_Ages)))+'月';
end;
end
else begin
vAges := IntToStr(YearsBetween(now,strToDate(prmt_Ages)))+'岁';
end;
这个函数可以计算出大于一岁的和小于一个月的精确年龄,但是对于大于一个月小于一年的年龄没有办法精确到【天】这个单位,只能计算出几个月。不知道各位有没有办法帮忙改一下。