• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to check current date less than previous date using IF statement

Rondog21

New Member
Hi guys

I'm not sure about how to check if one date is later than another by using IF statements because of dates being stored as values. E.g. I want to know if Feb is later than Jan using IF(FEB > JAN, "FEB is later than JAN", "JAN IS EARLIER THAN FEB") but this doesn't work.

I want to include an extra nested if statement before a vlookup which checks a certain date value from a report and returns me another text value if date value < current date.

So something like:
=IF(date value < current month date,"text",VLOOKUP(something from some table)).

How do I get around this dates stored as values problem?

Thanks

Rondog
 
Hi ,

Dates in Excel are just numbers , and you can compare one date with another by using the inequality or equality operators.

Thus , if by current month date you mean today's date , the Excel function which returns this value is the TODAY() function.

Thus an IF statement such as :

=IF(datevalue < TODAY() , "text" , VLOOKUP( ... ))

will work.

In fact dates stored as text present problems ; dates stored as dates i.e. numeric values pose absolutely no problem.

If you just want to compare the months , you can use two methods :

1. The MONTH( ... ) function returns the month for the date which is passed to it as a parameter ; thus :

=MONTH(TODAY())

will return 2 , since we are now in February.

2. The TEXT( ... ) function returns the alphabetic name of the month , either in the format Jan , Feb , Mar ,... or in the long format January , February , March ,...

Thus :

=TEXT(TODAY() , "mmm") will display Feb

=TEXT(TODAY() , "mmmm") will display February.

Narayan
 
Back
Top