ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to substract a date in excel to 2000 (https://www.excelbanter.com/excel-programming/378521-how-substract-date-excel-2000-a.html)

Ram

How to substract a date in excel to 2000
 
I want to get exact date (day/month/year) of a person as to when he will be
21 years of age in excel to 2000

eg. My birthdate is 12/12/1972 - 12/12/1993 = 21 years
the output should be in years as shown in eg.

Martin Fishlock

How to substract a date in excel to 2000
 
function years21(birthdate as date) as string
on error goto error_line
dim newdate as date
newdate = dateserial(year(birthdate)+21,month(birthdate),day (birthdate))
years21="My birthdate is " & _
format(birthdate,""dd/mm/yyyy") & " - " & _
format(newdate,""dd/mm/yyyy") & " = 21 years"
exit function
error_line:
years21="Error"
end function
--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"ram" wrote:

I want to get exact date (day/month/year) of a person as to when he will be
21 years of age in excel to 2000

eg. My birthdate is 12/12/1972 - 12/12/1993 = 21 years
the output should be in years as shown in eg.



All times are GMT +1. The time now is 07:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com