Date difference for partial dates

I am calculating age difference between birthdate & today's date. As in data, We have partial birthdate i.e. sometimes birthdates such as full date(2000-12-12), only year+month(2000-12) or only year(2000) is available.

How we can calculate age on available birthdate date part.

In SAS, we use below formula,
yrdif(date1, date2, "ACT/ACT")

I tried using R,
time_length(difftime(TODAYDT, BRTHDT), unit = "year"))
but for partial dates it doesn't work, Can you please let me know how I can address this?

Thank you,
Harshal

how do differences between partial dates and a full date get solved in your SAS code ; what assumption is being made about what the partial date represents ? If you can determine that, then you could instruct R to make similar assumptions.

In SAS, Actual part of dates been comparing. let's example of Today's date 06-09-2023 & birthdate is only 1987 then only year will consider while calculating AGE. In below formula,

yrdif(date1, date2, "ACT/ACT") , ACT/ACT argument taking actual portion from both dates.

your explanation is not sufficient.
if I give you only '1987' you in principle have no single way of counting days between that and any other date;
unless you make an assumption about what date '1987' represents.
i.e. december 31st of 1987 is different from january 1st of 1987 ; though dropping day and month info, both these very different dates would appear as '1987'

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.