Outline ·
[ Standard ] ·
Linear+
Microsoft Excel formulae....... How to do this?
|
wlcling
|
May 8 2008, 03:05 PM
|
|
oooo... i love excel challenges
Do you have a lot of different conditions or just two? If it's just two, here goes:-
Let's say you have date 1 on cell A1, and date 2 on cell B1 (I.e, you want to make a condition based on the number of months date 2 is from date 1)
First you need a simple formula to count the difference in months which is this:- =(MONTH(B1)-MONTH(A1))+((YEAR(B1)-YEAR(A1))*12)
Next to create the IF statement:- =IF((MONTH(B1)-MONTH(A1))+((YEAR(B1)-YEAR(A1))*12)=10,"Action A",IF((MONTH(B1)-MONTH(A1))+((YEAR(B1)-YEAR(A1))*12)=20,"Action B","No condition matched!"))
Done!
|
|
|
|
|
|
wlcling
|
May 8 2008, 03:15 PM
|
|
QUOTE(dopodplaya @ May 8 2008, 03:07 PM) use datediff la brother. gile panjang kod, tapi tak betul muahaha. datediff?? What is the syntax like, could you list it out?
|
|
|
|
|
|
wlcling
|
May 8 2008, 03:51 PM
|
|
QUOTE(dopodplaya @ May 8 2008, 03:20 PM) The syntax for DATEDIF is as follows: CODE =DATEDIF(Date1, Date2, Interval) Where: Date1 is the first date, Date2 is the second date, Interval is the interval type to return. Example - different of date in month CODE =DATEDIF(Date1,Date2,"m") Cool! Didn't know of such function. Thanks for sharing! QUOTE(suiteng @ May 8 2008, 03:37 PM) I just use date2 - date1 = answer  that would give the difference in days, so won't work for this case.
|
|
|
|
|