date formula - STUCK!

gino59

Active Member
Joined
Jul 26, 2010
Messages
496
Hi all!

I have two date values -
A1 = TODAY()
A2 = 12/8/1926

Using the following formula in cell D1:

=YEAR(A2)-YEAR(A1)-IF(OR(MONTH(A2)<MONTH(A1),AND(MONTH(A2)=MONTH(A1), DAY(A2)<DAY(A1))),1,0)&" years, "&MONTH(A2)-MONTH(A1)+IF(AND(MONTH(A2)>=DAY(A1)),12,IF(AND(MONTH(A2)>MONTH(A1),DAY(A2)<DAY(A1)),-1))&" months,"&A2-DATE(YEAR(A2),MONTH(A2)-IF(DAY(A2)<DAY(A1),1,0),DAY(A1))&" days"

I get -85 years, 8 months, 15 days

Not sure why it comes up with a negative for the years and also, it doesn't seem to be calculating correctly as the difference should be 84 years, 3 months, 15 days.

Any ideas where I'm going wrong?

Many many thanks!!

Cheers,
Gino
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Also, if I flip the values in A1 and A2 so that A1 = 12/8/1926 and A2 = TODAY(), I get 84 years, -9 months, 15 days in cell D1...

:confused:
 
Upvote 0
Hi all!

I have two date values -
A1 = TODAY()
A2 = 12/8/1926

Using the following formula in cell D1:


=YEAR(A2)-YEAR(A1)-IF(OR(MONTH(A2)<MONTH(A1),AND(MONTH(A2)=MONTH(A1), ?&MONTH(A2)-MONTH(A1)+IF(AND(MONTH(A2) years, DAY(A2)<DAY(A1))),1,0)&?>
I get -85 years, 8 months, 15 days

Not sure why it comes up with a negative for the years and also, it doesn't seem to be calculating correctly as the difference should be 84 years, 3 months, 15 days.

Any ideas where I'm going wrong?

Many many thanks!!

Cheers,
Gino
See this...

http://www.cpearson.com/Excel/datedif.aspx
 
Upvote 0
Try

=DATEDIF(A2,TODAY(),"y")&" y "&DATEDIF(A2,TODAY(),"ym")&" m "&DATEDIF(A2,TODAY(),"md")&" d"
 
Upvote 0
Thanks, VOG - perfect! And for T.Valko - thanks too - I had been trying the DATEDIF formula but without success. The link has some really good info!

Many thanks as always!
Cheers!
Gino
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,543
Members
452,924
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top