If current month excel

My first time here, my question is this:

I have 6 cells lets say A2,B2,C2,D2,E2,F2 each cell value is driven by formula.

Above each of those cells I have named months like A1=October, B1=November, C1=December, D1=January, E1=February, F2=March.

What i want to do is show the value of A2 since we are in October but don’t show the value of B2, C2, D2, E2, and F2, then once we are in November still show the value of A2 and B2 but not the rest, once December show A2, B2, C2 and so on.

The formula I’m using now is this:

=IF(MONTH(TODAY())>=10,(C27+D24)-(Q15+E35),"0") 

It works all good but when it comes to December and January I cant get it to work. If I use =IF(MONTH(TODAY())>=12 it wont show the value of December which is good but once January rolls in then the value of December will show 0.

Any help would be greatly appreciated, one more thing I can not use a macro. Thanks again

  • #2

Hi,

Try if(Month(Now()=Month(AM2),True,False)

  • #3

Hi,

Try if(Month(Now()=Month(AM2),True,False)

I tried the formula but I still get his error:

nt3vUY2.png

  • #4

My Bad,

=If(Month(Now())=Month(AM2),True,False) I missed a 2nd ) after Now

  • #5

This will suffice :-

to give the required result.

hth

  • #6

We’re almost there now.

The only thing is that the formula doesn’t take the current year into account. It shows TRUE for all dates which are in May no matter what year.

  • #7

We’re almost there now.

The only thing is that the formula doesn’t take the current year into account. It shows TRUE for all dates which are in May no matter what year.

Give this formula a try…

=TEXT(A1,»mmmyyyy»)=TEXT(NOW(),»mmmyyyy»)

  • #8

Give this formula a try…

=TEXT(A1,»mmmyyyy»)=TEXT(NOW(),»mmmyyyy»)

The issue seems to be the same with all the formulas. The month is correct but it is not limited to the current year (2015). I might not have been clear on that.

=TEXT(A1,»mmmyyyy»)=TEXT(NOW(),»mmmyyyy»

=If(Month(Now())=Month(AM2),True,False)

I have uploaded a spreadsheet with all the formulas here.

Last edited: May 8, 2015

  • #9

Your bad
You didn’t mention year in your OP so I didn’t take it into account.


=IF(AND(MONTH(NOW())=MONTH($Am$2),YEAR(NOW())=YEAR($AM$2)),True,False)

<COLGROUP><COL style=»WIDTH: 374pt; mso-width-source: userset; mso-width-alt: 18249″ width=499><TBODY>

</TBODY>

  • #10

What is the value in AM2? What is the cell number formatting of AM2?

It may help using specific values and examples to get the correct answer; otherwise Rick’s answer should work, as should:

Code:

=AND(MONTH(NOW())=MONTH($AM$2),YEAR(NOW())=YEAR($AM$2))

This post will guide you how to highlight cell if date is the current day or is in the current week or month in Excel. How do I highlight row if date is in current week or month with conditional formatting in Excel 2013/2016.

  • Highlight Cell if Date is in Current Day/Week/Month
  • Highlight Row if Date is in Current Day/Week/Month

Table of Contents

  • Highlight Cell if Date is in Current Day/Week/Month
  • Highlight Row if Date is in Current Day/Week/Month
    • Related Functions

To highlight the cell of current day or the date is in the current week or month, you can do the following steps:

#1 select the range of cells that you want to highlight date.

highlight cell or row if date 1

#2 go to HOME tab, click Conditional Formatting command under Styles group, and click Highlight Cells Rules menu from the drop down menu list, then select A Date Occurring sub menu. And the A Date Occurring dialog will appear.

highlight cell or row if date 2

#3 if you want to highlight the current day, then select Today option from the first drop down list box in the A Date Occurring dialog box, then choose one color that you want to fill the cell in the second drop down list box. Click Ok button.

highlight cell or row if date 3

Note: if you want to highlight the cell if date is in the current week, just choose This Week option from the first drop down list box. And if you want to highlight the cell if date is in the current month, just choose This Month from the first drop down list box.

#4 you should notice that the current date has been highlighted.

highlight cell or row if date 4

Highlight Row if Date is in Current Day/Week/Month


If you want to highlight the row that If the date in that row is equal to the current day or is in the current week or month, you can do the following steps:

#1 select the entire rows of data that contain date values.

highlight cell or row if date 1

#2 go to HOME tab, click Conditional Formatting command under Styles group, Click New Rule from the drop down menu list. And the New Formatting Rule dialog will open.

highlight cell or row if date5

#3 click Use a formula to determine which cells to format option in the New Formatting Rule dialog box, type the following formula in the Format values where this formulas is true text box.

highlight cell or row if date6

To highlight current date, use the following formula:

=$A2=TODAY()

To highlight row if date is in the current week, use the following formula:

=TODAY()-WEEKDAY(TODAY(), 3)=$A2-WEEKDAY($A2, 3)

To highlight row if date is in the current month, use the following formula:

=TEXT($A2,”mmyy”)=TEXT(TODAY(),”mmyy”)

Note: the Cell A2 is the first cell of your selected range.

#4 click Format button, and the Format Cells dialog will open. Click Fill tab, select on color that you want to use. Click Ok button.

highlight cell or row if date7

#5 click Ok button. You should see that the entire rows which contain the current day have been highlighted.

highlight cell or row if date8


  • Excel WEEKDAY function
    The Excel WEEKDAY function returns a integer value representing the day fo the week for a given Excel date and the value is range from 1 to 7.The syntax of the WEEKDAY function is as below:=WEEKDAY (serial_number,[return_type])…
  • Excel TODAY function
    The Excel TODAY function returns the serial number of the current date. So you can get the current system date from the TODAY function. The syntax of the TODAY function is as below:=TODAY()…
  • Excel Text function
    The Excel TEXT function converts a numeric value into text string with a specified format. The TEXT function is a build-in function in Microsoft Excel and it is categorized as a Text Function. The syntax of the TEXT function is as below: = TEXT (value, Format code)…

The IF function is one of the most useful Excel functions. It is used to test a condition and return one value if the condition is TRUE and another if it is FALSE.

One of the most common applications of the IF function involves the comparison of values.

These values can be numbers, text, or even dates. However, using the IF statement with date values is not as intuitive as it may seem.

In this tutorial, I will demonstrate some ways in which you can use the IF function with date values.

Syntax and Usage of the IF Function in Excel

The syntax for the IF function is as follows:

IF(logical_test, [value_if_true], [value_if_false])

Here,

  • logical_test is the condition or criteria that you want the IF function to test. The result of this parameter is either TRUE or FALSE
  • value_if_true is the value that you want the IF function to return if the logical_test evaluates to TRUE
  • value_if_false is the value that you want the IF function to return if the logical_test evaluates to FALSE

For example, say you want to write a statement that will return the value “yes” if the value in cell reference A2 is equal to 10, and “no” if it’s anything but 10.

You can then use the following IF function for this scenario:

=IF(A2=10,"yes","no")
A Simple IF formula

Comparing Dates in Excel (Using Operators)

Unlike numbers and strings, comparison operators, when used with dates, have a slightly different meaning.

Here are some of the comparison operators that you can use when comparing dates, along with what they mean:

Operator What it Means When Using with Dates
< Before the given date
= Same as the date with which we are comparing
> After the given date
<= Same as or before the given date
>= Same as or after the given date

It may look like IF formulas for dates are the same as IF functions for numeric or text values, since they use the same comparison operators.

However, it’s not as simple as that.

Unfortunately, unlike other Excel functions, the IF function cannot recognize dates.

It interprets them as regular text values.

So you cannot use a logical test such as “>05/07/2021” in your IF function, as it will simply see the value “05/07/2021” as text.

Here are a few ways in which you can incorporate date values into your IF function’s logical_test parameter.

Using the IF Function with DATEVALUE Function

If you want to use a date in your IF function’s logical test, you can wrap the date in the DATEVALUE function.

This function converts a date in text format to a serial number that Excel can recognize as a date.

If you put a date within quotes, it is essentially a text or string value.

When you pass this as a parameter to the DATEVALUE function, it takes a look at the text inside the double quotes, identifies it as a date and then converts it to an actual Excel date value.

Let us say you have a date in cell A2, and you want cell B2 to display the value “done” if the date comes before or on the same date as “05/07/2021” and display “not done” otherwise.

You can use the IF function along with DATEVALUE in cell B2 as follows:

=IF(A2<DATEVALUE("05/07/2021"),"done","not done")

Here’s a screenshot to illustrate the effect of the above formula:

IF Formula to check done or not

Using the IF Function with the TODAY Function

If you want to compare a date with the current date, you can use the IF function with the TODAY function in the logical test.

Let’s say you have a date in cell A2 and you want cell B2 to display the value “done” if it is a date before today’s date.

If not, you want let’s say you want to display the value “not done”. You can use the IF function along with the TODAY function in cell B2 as follows:

=IF(A2<TODAY(),"done","not done")

Here’s a screenshot to illustrate the effect of the above formula (assuming the current date is 05/08/2021):

IF Formula to check whether date is before today

Using the IF Function with Future or Past Dates

An interesting thing about dates in Excel is that you can perform addition and subtraction operations with them too.

This is because dates are basically stored in Excel as serial numbers, starting from the date Jan 1, 1900.

Each day after that is represented by one whole number.

So, the serial number 2 corresponds to Jan 2, 1900, and so on.

This means that adding n number of days to a date is equivalent to adding the value n to the serial number that the date represents.

If TODAY() is 05/07/2021, then TODAY()+5 is five days after today, or 05/12/2021. Similarly, TODAY()-3 is three days before today or 05/04/2021.

Let’s say you have a date in cell A2 and you want cell B2 to mark it as “within range” if it is within 15 days from the current date.

If not, you want to show “out of range”. You can use the IF function along with the TODAY function in cell B2 as follows:

=IF(A2<TODAY()+15,"within range","out of range")

Here’s a screenshot to illustrate the effect of the above formula (assuming the current date is 05/08/2021):

IF formula to check whether date is within range

Points to Remember

Having discussed different ways to use dates with the IF function, here are some important points to remember:

  1. Instead of hardcoding the dates into the IF function’s logical test parameter, you can store the date in a separate cell and refer to it with a cell reference. For example, instead of typing =IF(A2<”05/07/2021”,”done”,”not done”), you can store the date 05/07/2021 in a cell, say B2 and type the formula: =IF(A2<B2,”done”,”not done”).

IF formula to compare two dates

  1. Alternatively, you can use the DATEVALUE function as explained in the first part of this tutorial.

Using IF function with Datevalue

  1. Another neat technique that you can use is to simply add a zero to the date (which has been enclosed in double quotes). So you can type: =IF(A2<”05/07/2021”+0,”done”,”not done”). This will make Excel take the date inside double quotes as a serial number, and use it in the logical test without having its value changed.

Adding 0 to date within IF formula

In this tutorial, I showed you some great techniques to use the IF function with dates. I hope the tips covered here were useful for you.

Other articles you may also like:

  • Multiple If Statements in Excel (Nested Ifs, AND/OR) with Examples
  • How to use Excel If Statement with Multiple Conditions Range [AND/OR]
  • How to Convert Month Number to Month Name in Excel
  • Why are Dates Shown as Hashtags in Excel? Easy Fix!
  • How to Convert Serial Numbers to Date in Excel
  • How to Get the First Day Of The Month In Excel?

Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More…Less

This article describes the formula syntax and usage of the TODAY function
in Microsoft Excel.

Description

Returns the serial number of the current date. The serial number is the date-time code used by Excel for date and time calculations. If the cell format was General before the function was entered, Excel changes the cell format to Date. If you want to view the serial number, you must change the cell format to General or Number.

The TODAY function is useful when you need to have the current date displayed on a worksheet, regardless of when you open the workbook. It is also useful for calculating intervals. For example, if you know that someone was born in 1963, you might use the following formula to find that person’s age as of this year’s birthday:

=
YEAR(
TODAY())-1963

This formula uses the TODAY function as an argument for the YEAR function to obtain the current year, and then subtracts 1963, returning the person’s age.

Note: If the TODAY function does not update the date when you expect it to, you might need to change the settings that control when the workbook or worksheet recalculates. On the File tab, click Options, and then in the Formulas category under Calculation options, make sure that Automatic is selected.

Syntax

TODAY()

The TODAY function syntax has no arguments.

Note: Excel stores dates as sequential serial numbers so they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900.

Example

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.

Formula

Description

Result

=TODAY()

Returns the current date.

12/1/2011

=TODAY()+5

Returns the current date plus 5 days. For example, if the current date is 1/1/2012, this formula returns 1/6/2012.

12/6/2011

=DATEVALUE(«1/1/2030»)-TODAY()

Returns the number of days between the current date and 1/1/2030. Note that cell A4 must be formatted as General or Number for the result to display correctly.

1/31/1918

=DAY(TODAY())

Returns the current day of the month (1 — 31).

1

=MONTH(TODAY())

Returns the current month of the year (1 — 12). For example, if the current month is May, this formula returns 5.

12

Need more help?

Понравилась статья? Поделить с друзьями:
  • Idioms with the word set
  • If contains part of text excel
  • Idioms with the word round
  • If construction in excel
  • Idioms with the word right