IF function to return a message depending on month and year

Garetht2014

New Member
Joined
Oct 21, 2014
Messages
22
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am trying to work out how to use an IF function to put in the correct message I want to see.

I have a Start Date , Todays Date & Time Served column. In column K would like to populate that with a value.

So if the Time served is under Six months I would like the cell in Column K to show 0-6, 6 months to a year to show 6-12.

I thought I cracked it but for some reason it has put some of the cells that are over 6 months in the 0-6 category which isn't correct.

Anyone able to point me in the right direction please ?



1679657949879.png
 

Attachments

  • 1679657874603.png
    1679657874603.png
    25.8 KB · Views: 2

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Need to work on the actual number of months, not text.
 
Upvote 0
Is column J a formula? If so what.
 
Upvote 0
Column J is:
=DATEDIF(H3,I3,"y")&" years "&DATEDIF(H3, I3,"ym")&" months "

Welshgasman:

I don't understand what you mean. Could you elaborate a bit for me please ?
 
Upvote 0
Thanks for that.
How about
Excel Formula:
=LET(m,DATEDIF(H3,I3,"m"),IF(m<=6,"0-6",IF(m<=12,"6-12",">12")))
 
Upvote 0
Solution
Column J is:
=DATEDIF(H3,I3,"y")&" years "&DATEDIF(H3, I3,"ym")&" months "

Welshgasman:

I don't understand what you mean. Could you elaborate a bit for me please ?
You need to test for the number of months, not some text that has a number in it.
So....use a similar calculation as you show above to calculate how many actual months there are.
I do not have DateDIF in 2007 but would hazard a guess it would be

Code:
DATEDIF(H3, I3,"m")
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,791
Messages
6,121,611
Members
449,038
Latest member
apwr

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