Escolar Documentos
Profissional Documentos
Cultura Documentos
ablebits.com /office-addins-blog/2017/09/20/excel-today-function-insert-date/
The syntax of the TODAY function is as simple as it could possible be - it does not have any arguments at all.
Whenever you need to insert today's date in Excel, just enter the following formula in a cell:
=TODAY()
You can format the value returned by TODAY in any built-in or custom date format. For example, this way:
The value returned by the TODAY function updates automatically, so the below formula is useful if you want the
worksheet to always display the current date, regardless of when you open it.
=TODAY()
To clarify what kind of date that is, you can concatenate TODAY() with some explanatory text, for example:
Because in the internal Excel system dates and times are stored as numbers, concatenating text with the
TODAY() formula directly would result in a meaningless string like "Today is 42965". To avoid this, we nest
Excel's TODAY function within the TEXT function to display the date in the desired format.
The inset today's date as an unchangeable timestamp that won't automatically update the next day, use one of
the following keyboard shortcuts:
To add or subtract a specific number of days to/from the current date, use a simple arithmetic operation of
addition or subtraction, respectively.
=TODAY()+7
=TODAY()-7
To exclude weekends (Saturday and Sunday) from your calculations, nest the TODAY function within
WORKDAY that deals with weekdays only:
=WORKDAY(TODAY(), 7)
=WORKDAY(TODAY(), -7)
Tip. To display the calculated date correctly, set the formula cell's format to Date.
To calculate how many days are left before some data, subtract today's date from the future date you are
counting toward:
date-TODAY()
The date can be supplied directly to a formula in the format that Excel can understand, or by using the DATE
function, or as a reference to the cell containing the date.
For example, to find out how many days are left till December 31, 2017, use one of these formulas:
=A2-TODAY()
=DATE(2017,12,31)-TODAY()
="12/31/2017"-TODAY()
2/6
All three formulas tell us that at the moment of writing (August 17, 2017), 136 days were left till the end of the
year 2017:
To calculate the number of days since a certain date, subtract the past date from today's date:
TODAY()-date
For example, to find out how many days have passed since January 1, 2017, use one of these formulas:
=TODAY()-A2
=TODAY()-DATE(2017,1,1)
=TODAY()-"1/1/2017"
Tip. If the result is not displayed correct, be sure to apply the General format to the formula cell.
To get the number of months between today and a past date, use the DATEDIF(start_date, end_date, unit)
function with the past date in the start_date argument, TODAY() as end_date and "m" unit denoting months:
To get the number of months between today and a future date, swap the start_date and end_date arguments:
DATEDIF(TODAY(), future-date,"m")
With the date of interest in cell A4, use the following formulas to calculate time difference in the number of
complete months:
=DATEDIF(A4,TODAY(),"m")
=DATEDIF(TODAY(),A4,"m")
The formulas to calculate years based on today's date are similar to the ones discussed in the above example.
The difference is that you use "y" unit to get the number of complete years between today and another data:
3/6
DATEDIF(past_ date, TODAY(),"y")
DATEDIF(TODAY(), future-date,"y")
Assuming the past/future date is in cell A4, you should be good with using these formulas:
=DATEDIF(A4,TODAY(),"y")
=DATEDIF(TODAY(),A4,"y")
For more information about the DATEDIF function, please see Excel DATEDIF - calculate difference between
two dates.
If you know someone's year of birth, you can subtract that year from the current year to find the person's age:
YEAR( TODAY())-year_of_birth
For example, if the person was born in 2000, you use the following formula to get his/her age:
=YEAR( TODAY())-
2000
Or, you can enter the year of birth in a separate cell and reference that cell in your formula:
You can learn a few other age calculation formulas in this tutorial: How to get age
from date of birth in Excel.
If you are curious to know which date in a list is closest to today's date, use one
of the following array formulas to find it out.
To find a past date nearest to the current date, first "filter out" the dates greater than today, and then use the MAX
function to get the largest date among the remaining ones:
4/6
Get a future date closest to today
To find the nearest future date, identify the dates that are greater than today, and
then use the MIN function to get the smallest date among them:
To get the nearest date in a mixed list of past and future dates, use the classic
INDEX MATCH formula with a couple of modifications:
MIN(ABS(range -TODAY())) part. First, you subtract today's date from each date in the range of dates.
Then, the ABS function returns the differences as absolute values without regard to their sign. The MIN
finds the minimal value, which goes to INDEX MATCH as the lookup value.
ABS(range -TODAY()) part. You subtract today's date from the range of dates and return an array of
absolute values. This array is where INDEX MATCH searches for the lookup value.
Note. All three formulas to get the nearest date are array formulas, so they should be completed by pressing
Ctrl + Shift + Enter.
When working with a long list of dates or designing your own calendar in Excel, you may want to have the current
date highlighted. To have it done, create a conditional formatting rule with this formula:
=B2=TODAY()
Where B2 is the left-top-most cell of the range to which the rule applies.
5/6
The detailed steps to set up a conditional formatting rule can be found here: How to create a conditional
formatting rule based on formula.
To have a closer look at the formulas discussed in this tutorial, you are welcome to download our Excel Today's
Date workbook.
For more examples of using the TODAY function in Excel, please check out the following tutorials:
6/6