I want to calculate age with birth day and current day. result should be "years-month-day".How can i do ? Please help.
我想计算出生日和当天的年龄。结果应该是“年 - 月 - 日”。我该怎么办?请帮忙。
i'm try this but not be great
我试试这个,但不是很好
DateDiff(“yyyy”,birthday,currentday)
if current date is 20/05/2015 and birth date is 1/06/1991, result = 24 but it should be 23 years 5 month 19 days
如果当前日期是2015年5月20日,出生日期是1/06/1991,结果= 24但应该是23年5个月19天
1 个解决方案
#1
If (Not(isNull({@birthdate}))) Then
ToText(int(DateDiff('d',{@birthdate},CurrentDate())/365.25),0)+' Years '+
ToText(int(remainder(DateDiff('d',{@birthdate},CurrentDate()),365.25)/30),0)+' Months '+
If day(CurrentDate()) < Day({@birthdate}) Then
ToText(day(dateserial(year({@birthdate}), Month({@birthdate})+1,1-1)) - Day({@birthdate}) + Day(CurrentDate()),0) + ' days'
Else
ToText(day(CurrentDate()) - day({@birthdate}),0) + ' days'
No perfect but works nicely.. here is an article to read that might help as well for calculating birthdays
没有完美,但工作得很好..这里有一篇文章,可能有助于计算生日
#1
If (Not(isNull({@birthdate}))) Then
ToText(int(DateDiff('d',{@birthdate},CurrentDate())/365.25),0)+' Years '+
ToText(int(remainder(DateDiff('d',{@birthdate},CurrentDate()),365.25)/30),0)+' Months '+
If day(CurrentDate()) < Day({@birthdate}) Then
ToText(day(dateserial(year({@birthdate}), Month({@birthdate})+1,1-1)) - Day({@birthdate}) + Day(CurrentDate()),0) + ' days'
Else
ToText(day(CurrentDate()) - day({@birthdate}),0) + ' days'
No perfect but works nicely.. here is an article to read that might help as well for calculating birthdays
没有完美,但工作得很好..这里有一篇文章,可能有助于计算生日