Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Microsoft Excel formulae....... How to do this?

views
     
wlcling
post May 8 2008, 03:05 PM

Hippidy Hoppidy
*******
Senior Member
2,711 posts

Joined: Sep 2005


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
post May 8 2008, 03:15 PM

Hippidy Hoppidy
*******
Senior Member
2,711 posts

Joined: Sep 2005


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
post May 8 2008, 03:51 PM

Hippidy Hoppidy
*******
Senior Member
2,711 posts

Joined: Sep 2005


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 sweat.gif
*
that would give the difference in days, so won't work for this case.

 

Change to:
| Lo-Fi Version
0.0147sec    0.48    6 queries    GZIP Disabled
Time is now: 12th December 2025 - 10:19 AM