How to use the NOW function
What is the NOW function?
The NOW function returns the current date and time. It is a volatile function.
Table of Contents
1. Introduction
What is time in Excel?
Excel time value is a number equal to or larger than 0 (zero) and smaller than 1, formatted as a time value. One hour is 1/24, there are 24 hours in one day.
One minute is 1/1440, there are 1440 minutes in one day (60*24 = 1440). One second is 1/86400, there are 86400 seconds in one day (60*60*24 = 86400).
The following table shows whole hours, one hour is 1/24, 2 hours is 2/24, and so on.
0 - 12:00:00 AM
1/24 - 1:00:00 AM
2/24 - 2:00:00 AM
...
23/24 - 11:00:00 PM
24/24 - 12:00:00 AM
The time value is only the decimal part of a number, in other words, a value larger than or equal to 1 makes no difference, Excel uses only the decimal part of a number to create an Excel time value.
1.5 -> 0.5 -> 12:00:00 PM
The whole numbers represent dates in Excel. The whole number and the decimal part create a date and time value. Here is an example: 1.5 represents 1/1/1900 12:00 PM
What are dates in Excel?
Dates are stored numerically but formatted to display in human-readable date/time formats, this enables Excel to do work with dates in calculations.
For example, dates are stored as sequential serial numbers with 1 being January 1, 1900 by default. The integer part (whole number) represents the date the decimal part represents the time.
This allows dates to easily be formatted to display in many date/time formats like mm/dd/yyyy, dd/mm/yyyy and so on and still be part of calculations as long as the date is stored numerically in a cell.
What is a volatile function?
The NOW function is a volatile function, it updates each time you recalculate the worksheet.
What is the effect of volatile functions?
They may slow down your worksheet/workbook if you have many volatile functions. Use with caution, it may slow down your workbook considerably if used extensively.
When is the worksheet calculated?
Cells containing non volatile functions are only calculated once or until you force a recalculation, however, volatile functions are recalculated each time you type in a cell and press enter.
Can you stop recalculating a worksheet?
Yes, you can change a setting to manual recalculations.
- Go to tab "Formulas".
- Press with left mouse button on the "Calculation Options" button, a popup menu appears.
- Press with mouse on "Manual".
This stops the automatic recalculations.
How to force a recalculation?
Pressing F9 key will recalculate or refresh all the formulas and values in every worksheet of every workbook you have open.
Pressing Shift+F9 will only recalculate the formulas and values on the single worksheet you're currently viewing or active.
Pressing Ctrl+Alt+F9 is the quickest way to force a full recalculation of absolutely everything in all open workbooks, even if nothing has changed. It ignores whether changes were made or not and completely recomputes.
Are there more volatile functions in Excel?
Yes. OFFSET, TODAY, RAND among others.
Function | Syntax | Description |
---|---|---|
OFFSET | OFFSET(reference, rows, cols) | Returns a cell offset from a reference cell. |
TODAY | TODAY() | Returns the current date. |
RAND | RAND() | Returns a random decimal between 0 and 1. |
RANDARRAY | RANDARRAY([rows], [columns], [min], [max], [whole_number]) | Returns an array with random numbers. |
RANDBETWEEN | RANDBETWEEN(bottom, top) | Returns a random whole number between bottom and top |
Note, that conditional formatting is extremely volatile or super-volatile meaning it is recalculated as you scroll through a worksheet.
2. Syntax
NOW()
The NOW function has no arguments.
3. Example 1
This example shows different ways you can use the NOW function. Cell B3 returns the current date and time value which Excel formats as year, month, day, etc.
Formula in cell B3:
The formula in cell E2 calculates the year based on the output from the NOW function:
The formula returns 2024 which represents the current year. The formula in cell E3 extracts the month from the NOW function's result:
This formula displays 8, indicating the eighth month of the year (August). The formula in cell E4 determines the day of the month using the NOW function:
It produces 22, corresponding to the 22nd day of the current month. The formula in cell E5 computes the day of the week from the NOW function's output:
The result 5 signifies the fifth day of the week (Thursday, assuming Sunday is day 1). The formula in cell E6 ascertains the week number within the year:
It returns 34, denoting the 34th week of the current year. The formula in cell E7 derives the hour from the NOW function's timestamp:
The output 8 represents the 8th hour of the day in 24-hour format. The formula in cell E8 extracts the minute component from the NOW function:
It shows 42, indicating 42 minutes past the hour. The formula in cell E9 retrieves the seconds from the NOW function's result:
The value 25 reflects the number of seconds elapsed in the current minute.
All these examples refreshes automatically every time the worksheet is recalculated, this is why it is a volatile function. The advantage is that you always have an accurate up to date value you can work with.
4. Example 2
The image shows a spreadsheet with information about a project's elapsed time. Cell B3 contains the project start date: 6/1/2024. The formulas in cells E3 and E4 calculate the elapsed time since the project started:
Formula in cell E3:
This formula calculates the number of whole days that have passed since the project start date. It subtracts the start date from the current date and time (NOW()), then rounds down to the nearest integer. The result shown is 82 days.
- NOW(): Returns the current date and time.
- B3: This is a reference to a cell that contains a date and time value.
- NOW()-B3: Subtracts the value in cell B3 from the current date and time, resulting in a time difference.
- ROUNDDOWN(...,0): Rounds down the time difference to the nearest whole number (i.e., the nearest day). The 0 argument specifies that we want to round down to the nearest whole number.
Formula in cell E3:
This formula calculates the additional hours beyond the whole days. It first subtracts the start date from the current date/time, then subtracts the integer part of this difference (whole days), leaving only the fractional part. The HOUR function then extracts the hours from this fraction. The result shown is 9 hours.
- NOW(): Returns the current date and time.
- B3: This is a reference to a cell that contains a date and time value.
- NOW()-B3: Subtracts the value in cell B3 from the current date and time, resulting in a time difference.
- INT(NOW()-B3): Converts the time difference to an integer, effectively removing the fractional part (i.e., the hours, minutes, and seconds). This leaves us with the whole number of days.
- NOW()-B3-INT(NOW()-B3): Subtracts the whole number of days from the original time difference, leaving us with the remaining hours, minutes, and seconds.
- HOUR(...): Extracts the hour component from the remaining time difference.
According to the spreadsheet, 82 days and 9 hours have elapsed since the project started on 6/1/2024.
5. Calculate time between time zones
This article demonstrates how to build a time zone chart and calculate times different than your time zone.
The worksheet below lets you enter cities and their time difference. Excel calculates the corresponding local times in E5:E8. Press F9 to refresh the time and date in cell E3.
What's on this section
- How to calculate time zone differences
- Find the time difference
- How to create a time zone chart
- How I built the chart
- Values and formulas
- Insert a drop down list
- Insert a column Chart
- Adjust and remove vertical axis
- Remove legend and major horizontal gridlines
- Add vertical grid lines
- Add map to chart background
- Adjust column gap width and transparency
- How I built the chart
- Get Excel file
5.1. How to calculate time zone differences
This worksheet lets you enter cities and their time difference. Excel calculates the corresponding local times in E5:E8. Press F9 to refresh the time and date in cell E3.
Formula in cell E3:
Formula in cell E5: =$E$3+C5/24 Copy this cell and paste to E6:E8. There are both absolute and relative cell references in this formula.
Did you know that Excel stores date and time as a number? 16 June 2015 is stored as 42171. 16 June 2015 12:00 is 42171.5. Time is the decimal part of the number (0.5) and the date is 42171.
You can verify that this is true, type a date in a cell. Select the cell and press CTRL + 1. Change the formatting to General.
To add 7 hours to a datetime value you need to divide the hours by 24. 7/24 + 42171 = 42171.02916667. That explains the formula in cell E5: =$E$3+C5/24
Another example, 24 hours (1 day) is equal to 1. 42171 + 24 hours is 42171 + 24/24 = 42172.
5.2. Find the time difference
How do you know the time difference between where you live and another city/country? You don't, some countries use daylight saving time (summertime) or have changed their time zone. It can be really confusing.
Go to https://www.timeanddate.com/worldclock/ and search for a city, it is the only way.
Type the time difference in column C, Excel calculates the time for you in column E.
5.3. How to create a time zone chart
This chart shows you the world divided into 24 time zones, in a perfect world this could be useful. Unfortunately, it is pretty much useless.
Don't use this chart to find the time difference between the two cities. It is not accurate, some countries have changed their time zone and use daylight saving time.
I have included this chart in this post only to show you how I built it.
5.3.1 How I built the chart
5.3.1.1 Values and formulas
- Go to sheet2
- Type these values in columns B and C, see pic below.
- Type this formula in cell D2: =IF(B2=Sheet1!$D$12, 1, 0)
- Copy cell D2 and paste to D3:D26
7.3.1.2 Insert a Drop-down List
- Go to sheet1, select cell D12
- Go to tab "Data"
- Press with left mouse button on the "Data Validation" button
- Select List
- Enter these numbers: -12, -11, ... -1, 0, +1, ... , +14
- Press with left mouse button on OK.
5.3.1.3 Insert a column Chart
- Go to sheet2.
- Select cell range B2:C26.
- Go to tab "Insert" on the ribbon.
- Press with left mouse button on the "Column chart" button.
- Press with right mouse button on on the chart and press with left mouse button on "Select Data...".
- Press with left mouse button on the "Edit" button below Horizontal (Category) Axis Labels.
- Select cell range B2:B26.
- Press with left mouse button on OK.
- Select "Series1".
- Press with left mouse button on the "Edit" button.
- Select cell range C2:C26 as series values.
- Press with left mouse button on OK.
- Select Series2.
- Press with left mouse button on "Remove" button.
- Press with left mouse button on OK.
7.3.1.4 Adjust and remove vertical axis
- Press with right mouse button on on the vertical axis.
- Press with left mouse button on "Format Axis...".
- Change "Maximum Value" to "Fixed" and type 1.
- Press with left mouse button on "Close" button.
- Select "Vertical Axis" and press Delete.
5.3.1.5 Remove legend and major horizontal gridlines
- Select "Legend".
- Delete "Legend".
- Select major horizontal gridlines.
- Delete.
5.3.1.6 Add vertical grid lines
- Select chart.
- Go to tab "Layout" on the ribbon.
- Press with left mouse button on "Gridlines" button.
- Press with left mouse button on "Primary Vertical Gridlines".
- Press with left mouse button on "Major Gridlines".
5.3.1.7 Add map to chart background
I found a world map at wikimedia commons. Copy picture (Ctrl + C)
- Press with right mouse button on on plot area.
- Press with left mouse button on "Format Plot Area...".
- Press with left mouse button on "Picture or texture fill".
- Press with left mouse button on "Clipboard" button.
- Press with left mouse button on Close button.
5.3.1.8 Adjust column gap width and transparency
- Press with right mouse button on on the column.
- Press with left mouse button on "Format Data Series...".
- Change gap width to 0%.
- Go to the "Fill" category.
- Press with left mouse button on "Solid fill".
- Change transparency to 50%.
- Press with left mouse button on the Close button.
6. Function not working
The NOW function returns
- a #NAME! error if the function name is misspelled.
- a decimal value if the cell is not formatted as a date and time value.
6.1 Troubleshooting the error value
When you encounter an error value in a cell a warning symbol appears, displayed in the image above. Press with mouse on it to see a pop-up menu that lets you get more information about the error.
- The first line describes the error if you press with left mouse button on it.
- The second line opens a pane that explains the error in greater detail.
- The third line takes you to the "Evaluate Formula" tool, a dialog box appears allowing you to examine the formula in greater detail.
- This line lets you ignore the error value meaning the warning icon disappears, however, the error is still in the cell.
- The fifth line lets you edit the formula in the Formula bar.
- The sixth line opens the Excel settings so you can adjust the Error Checking Options.
Here are a few of the most common Excel errors you may encounter.
#NULL error - This error occurs most often if you by mistake use a space character in a formula where it shouldn't be. Excel interprets a space character as an intersection operator. If the ranges don't intersect an #NULL error is returned. The #NULL! error occurs when a formula attempts to calculate the intersection of two ranges that do not actually intersect. This can happen when the wrong range operator is used in the formula, or when the intersection operator (represented by a space character) is used between two ranges that do not overlap. To fix this error double check that the ranges referenced in the formula that use the intersection operator actually have cells in common.
#SPILL error - The #SPILL! error occurs only in version Excel 365 and is caused by a dynamic array being to large, meaning there are cells below and/or to the right that are not empty. This prevents the dynamic array formula expanding into new empty cells.
#DIV/0 error - This error happens if you try to divide a number by 0 (zero) or a value that equates to zero which is not possible mathematically.
#VALUE error - The #VALUE error occurs when a formula has a value that is of the wrong data type. Such as text where a number is expected or when dates are evaluated as text.
#REF error - The #REF error happens when a cell reference is invalid. This can happen if a cell is deleted that is referenced by a formula.
#NAME error - The #NAME error happens if you misspelled a function or a named range.
#NUM error - The #NUM error shows up when you try to use invalid numeric values in formulas, like square root of a negative number.
#N/A error - The #N/A error happens when a value is not available for a formula or found in a given cell range, for example in the VLOOKUP or MATCH functions.
#GETTING_DATA error - The #GETTING_DATA error shows while external sources are loading, this can indicate a delay in fetching the data or that the external source is unavailable right now.
6.2 The formula returns an unexpected value
To understand why a formula returns an unexpected value we need to examine the calculations steps in detail. Luckily, Excel has a tool that is really handy in these situations. Here is how to troubleshoot a formula:
- Select the cell containing the formula you want to examine in detail.
- Go to tab “Formulas” on the ribbon.
- Press with left mouse button on "Evaluate Formula" button. A dialog box appears.
The formula appears in a white field inside the dialog box. Underlined expressions are calculations being processed in the next step. The italicized expression is the most recent result. The buttons at the bottom of the dialog box allows you to evaluate the formula in smaller calculations which you control. - Press with left mouse button on the "Evaluate" button located at the bottom of the dialog box to process the underlined expression.
- Repeat pressing the "Evaluate" button until you have seen all calculations step by step. This allows you to examine the formula in greater detail and hopefully find the culprit.
- Press "Close" button to dismiss the dialog box.
There is also another way to debug formulas using the function key F9. F9 is especially useful if you have a feeling that a specific part of the formula is the issue, this makes it faster than the "Evaluate Formula" tool since you don't need to go through all calculations to find the issue.
- Enter Edit mode: Double-press with left mouse button on the cell or press F2 to enter Edit mode for the formula.
- Select part of the formula: Highlight the specific part of the formula you want to evaluate. You can select and evaluate any part of the formula that could work as a standalone formula.
- Press F9: This will calculate and display the result of just that selected portion.
- Evaluate step-by-step: You can select and evaluate different parts of the formula to see intermediate results.
- Check for errors: This allows you to pinpoint which part of a complex formula may be causing an error.
The image above shows NOW() function converted to hard-coded value using the F9 key. The function returns a numerical value representing an Excel date and time value. This value is not easy to read as date and time, you need to format the value in order to see the actual date and time.
Tips!
- View actual values: Selecting a cell reference and pressing F9 will show the actual values in those cells.
- Exit safely: Press Esc to exit Edit mode without changing the formula. Don't press Enter, as that would replace the formula part with the calculated value.
- Full recalculation: Pressing F9 outside of Edit mode will recalculate all formulas in the workbook.
Remember to be careful not to accidentally overwrite parts of your formula when using F9. Always exit with Esc rather than Enter to preserve the original formula. However, if you make a mistake overwriting the formula it is not the end of the world. You can “undo” the action by pressing keyboard shortcut keys CTRL + z or pressing the “Undo” button
6.3 Other errors
Floating-point arithmetic may give inaccurate results in Excel - Article
Floating-point errors are usually very small, often beyond the 15th decimal place, and in most cases don't affect calculations significantly.
'NOW' function examples
Functions in 'Date and Time' category
The NOW function function is one of 22 functions in the 'Date and Time' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form