# Age diff

Hey guys

Need some help pls, i have to calculate in my excel for example from age 67 to date 21.10.2010 how old that pers had, and put all this in my uipath work, i have 22 of them dates in my excel to calculate, how can i put them all in a formula?

Hi
If possible can we have a sample excel so that we could come up with a xaml
Cheers @poana

test.xlsx (11.4 KB) so the first age is 67 and the column E and under the rest of 22 ages and in the column B you have tha data from where i have to calculate age that was then.

1 Like

Great
but I m still not clear with thisâ€¦sorry for that
can you give us a sample calculation on this
Cheers @poana

That is my point, i didn t do no calculation, i don t get the formula how it works on 22 persons with different ages to calculate how old they were in the dates from Column B in my excel.

Hi @poana

You want to add ages to their corresponding dates, right ?

New Date â€”> 21.10.2077
likewise you want it on all 22 rows, correct me if iâ€™m wrong.

for this, ReadRange to get data from excel into DataTable and youâ€™ve to use For Each Row
(for each row In DT(output variable of read range))loop, in that loop you need to add following sequence of activities.

1. Assign â€”> Date1Str (String) = row(1).ToString â€”> by this youâ€™ll get date in string format.
2. Assign â€”> Date1 (DateTime) = Datetime.ParseExact(Date1Str,â€śdd.MM.yyyyâ€ť,System.Globalization.CultureInfo.InvariantCulture) â€”> by this datestring converted into DateTime variable.
3. Assign Age (Int32) = CInt(row(4).ToString) â€”> get age from datatable.
4. Assign NewDate (DateTime) = Date1.AddYears(Age) â€”> by this age (years) adds on date.
OR
5. If you want to Minus years from date then, use thisâ€”> Date1.AddYears(-Age)

here Iâ€™m attaching xaml, If you need it. Age.zip (20.7 KB)