Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Determining Differences Between Dates.

Determining Differences Between Dates

Written by Allen Wyatt (last updated May 4, 2024)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021


When you are programming macros, you should know that dates are stored internally, within variables, as serial numbers. The serial number represents the number of days elapsed since a starting "base date," specifically since 1 January 100. (Yes, that's the year 100.) This means that you can perform math with the serial numbers, if desired. You can, for instance, find the number of days between two dates by simply subtracting the dates from each other.

If you want to get fancier in your date calculations, you can use the DateDiff function. This function allows you, for instance, to determine the number of weeks or months between two dates. In order to use the function to find this type of information, you would do as follows:

iNumWeeks = DateDiff("ww", dFirstDate, dSecondDate)
iNumMonths = DateDiff("m", dFirstDate, dSecondDate)

The first line determines the number of weeks between the two dates, and the second determines the number of months between them. Note that the only difference between these two examples is the first parameter, either "ww" for weeks or "m" for months. Those aren't the only interval types you can specify within DateDiff. You can use any of these:

Interval Meaning
s seconds
n minutes
h hours
d days
y day of year (same as days)
w weeks
ww calendar weeks
m months
q quarters
yyyy years

If you want additional information about DateDiff, you can find it at this Microsoft site:


If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12380) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Word here: Determining Differences Between Dates.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Sorting by Five Columns

Excel allows you to sort but up to three columns, but you may want to sort by more than that. This tip provides ways you ...

Discover More

Putting Something in Every Cell of a Table

Need to make sure that all the cells of a table have something in them? It's easy to do with a handy little macro.

Discover More

Unknown Non-Printing Characters

When you paste information into Word from the internet, you may get more than just the plain text you hoped for. This tip ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

More WordTips (ribbon)

Editing Word's Built-in Commands

Want to configure Word to do just what you want it to? You can even go so far as to change the actual way in which Word ...

Discover More

Determining the Day of the Month

When writing macros, you may need to know which day of the month a particular date represents. Here's how to use the Day ...

Discover More

Repaginating Your Document in a Macro

When processing a document with a macro, you may need to have the macro repaginate the text. It's easy to do using the ...

Discover More

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 4 - 1?

2024-05-08 23:46:18


Another small difference between VBA and Worksheet function:
=DateSerial(200, 2, 28) will evaluate to a serial number for Feb. 28, 0200

Worksheet function:
=Date(200,2,28) will evaluate to Feb. 28, 2100. Weird!

ON that weird note, both functions accept parameters that are out of range like 35 or 61 for day, and 13 or 24 for month. For day and month the negative numbers are accepted too!
=Date(2024,-6,1) --> June 1, 2023
=Date(2024,16,-15) --> May 16, 2025
This can be used creatively, for instance to get the date that is 44 days from the Mar. 1, 2024 =DATE(2024,3,45).

2024-05-08 23:14:05


When using date calculations in Excel you have to be aware of some idiosyncrasies, and differences between dates in the worksheet and in VBA.
Let’s first clarify the statement from the tip: “The serial number represents the number of days elapsed since a starting "base date," specifically since 1 January 100. (Yes, that's the year 100.)”

While it is true that the earliest VBA date is January 1, 0100, the serial number assigned to this date is not zero nor one but -657434. The day assigned the serial number 1 in VBA is actually Dec. 31, 1899. Hence, Jan. 1, 1900 is assigned serial number 2. This is significant, because that date (Jan. 1, 1900 ) in worksheet is assigned serial number 1. Why this discrepancy? Because in the worksheet, the year 1900 is treated as a leap year, **which it is not**.

This one-day discrepancy carries through from Jan. 1 to Feb 28, 1900. The worksheet will even accept 1900-02-29 as valid date, but there was not such a day in Gregorian calendar. Starting with March 1, 1900 both worksheet and VBA match the date serial numbers, so for most common uses this is not an issue. The conclusion of this is that you need to keep it in mind, if any of the dates you use in your calculations are in this two-month period.

VBA handles the leap-year calculation correctly, assigning negative numbers to pre-1900 dates. However, there is no **simple way**, i.e., no format, that would display a pre 1900 date in a worksheet. Negative serial numbers formatted as date show as string of “#” filling the cell. On the other hand, you can use various tricks to handle those dates, some of them described in another tip:
There is a link there, that is now outdated, to another web resource; use the following instead:

On top of that, there is an issue of dates in Gregorian vs. Julian calendars. The switch was first implemented in four countries and the first date in this Gregorian calendar was Oct. 15, 1582. France was next on Dec, 20,1582. Other countries followed at different times until 1927! UK, USA and Canada started on Sep. 14, 1752. In all countries that switched from Julian to Gregorian calendar there was a missing period of 10 (Italy) to 13 days (Turkey) that were removed from the calendar. Excel VBA does not account for that (it really cannot, as it is different depending on the country). It just applies Gregorian dates backwards all the way to January 1, 100. The short of it is that if you want to count number of days between two dates you have to manually account for this discrepancy. How to do this is a whole different story. Probably the best approach would be to first convert any Julian date to equivalent Gregorian one, and only then do the math.

This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.


FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.