• 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.

using if conditions

jayalaxmi

Active Member
Dear All,

I am trying to use if conditions the criteria is if suppose for eg if its today's date then i have to print "FTD" and if its current month i want to print "MTD" and if suppose it is current year i want to print it as "YTD". taking eg as 11/05/2016. Any help appreciated..thanks for reading

Regards
jaya
 
Hi and welcome back Jaya.

I am not sure how you are entering {today's date, current month, current year}.

Try this:
=IF(A2=TODAY(),"FTD",IF(A2=MONTH(TODAY()),"MTD",IF(A2=YEAR(TODAY()),"YTD","")))

if you enter today's date (e.g. 11/05/2016), it will return FTD
if you enter current month (e.g. 05), it will show MTD
if you enter current year (e.g. 2016), result will be YTD
else Blank

Regards,
 
Hello Khalid,

hope you are doing well, I had tried the same..IF(B2=TODAY(),"FTD",IF(B2=MONTH(TODAY()),"MTD",IF(B2=YEAR(TODAY()),"YTD",0))) but I am showing results up as 0. I am not getting it whats wrong..

Regards
jaya
 
Small change in you code is required, the cell month and Cell year should read to match if condition, in your formula its stating B2 for month and year, rather it should say =Month(B2) or Year(B2)
Hello Khalid,

hope you are doing well, I had tried the same..IF(B2=TODAY(),"FTD",IF(B2=MONTH(TODAY()),"MTD",IF(B2=YEAR(TODAY()),"YTD",0))) but I am showing results up as 0. I am not getting it whats wrong..

Regards
jaya
 
Hello I would like to add one more thing I want the results to be "FTD" if it is today's date. But it is relfecting as "MTD".:( Pls help on the same.


Regards
 
Please check the attached doc, its working fine for me.
 

Attachments

  • Jaya.xlsx
    10.2 KB · Views: 1
Try this,

=IF(--B2=TODAY(),"FTD",IF(MONTH(B2)=MONTH(TODAY()),"MTD",IF(YEAR(B2)=YEAR(TODAY()),"YTD","")))

Edit :

1] your column B "Dates" are text value,

2] add "--" in front of B2, convert text to numeric value.

Regards
Bosco
 
Last edited:
I am not getting it whats wrong..

Hi Jaya,

Your dates in column B are not real dates.

The formula:
=IF(B2=TODAY(),"FTD",IF(MONTH(B2)=MONTH(TODAY()),"MTD",IF(YEAR(B2)=YEAR(TODAY()),"YTD","")))

will work, you just need to convert these dates into real dates, try:
  • Select your range B2:B296
  • Go to Data
  • Text to Columns
  • Finish
Or see the use of -- in Bosco's formula, it is doing the same (i.e. converting text date into number date)

Regards,
 
Back
Top