If/Then using dates

MN_Excel

Board Regular
Joined
Nov 8, 2010
Messages
153
I'm attempting to use a formula to calculate product expiration dates. If the date in a particular cell is before 5/1/11 I would like the expiration date to be the cell date plus 3 months. If it is after that date I would like the expiration date to be the cell date plus 6 month? For example, a cell with date 4/1/11 would have an expiration date of 7/1/11 while a cell with date of 6/1/11 would have a expiration date of 12/1/11. Any suggestions on how to write this formula?

Thanks in advance!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try

=IF(A1<"5/11/11"+0,DATE(YEAR(A1),MONTH(A1)+3,"DAY(A1)),DATE(YEAR(A1),MONTH(A1)+6),DAY(A1)))
 
Upvote 0
If you are using a version of Excel prior to XL2007, you will need to load the Analysis Toolpak for this:

=EDATE(A1,IF(A1<"5/11/11"+0,3,6))

or

without it:

=DATE(YEAR(A1),MONTH(A1)+IF(A1<"5/11/11"+0,3,6),DAY(A1))

Format as date.
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,158
Members
452,892
Latest member
yadavagiri

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