You are here:

# Excel/Formula help - date within 30 days

Question
Hi,

I am doing a check to see if data is correct. I have a spreadsheet which shows 2 dates, these should be within 30 days of each other. I want a formula that will check this and show a "t" (true) or "f" (false) to stop me from having to manually look at thousands of dates!

Hope you can help.

Cat :)

P.s I am using Excel 2010

Cat

I will assume the earliest date is in A1 and the lastest date is in B1 and the formula will be in C1.

A1:  First Date  (assume this is the earliest date)
B1:  Second Date  (assume this is the latest date)
C1:  =if((B1-A1)<=30,"t","f")

If you have more date pairings going down columns A and B, then you can select C1 and drag fill it down column C.

Dates are stored as the number of days from a specific base date.  So if you subtract the earliest date from the lastest date, then you will get the difference as the number of days apart.

Now just as if I subtract 1 from 10, the answer is 9,  So it will be for the two dates.  You will have to assess your standard and see how you define the 30 limitation.  If it includes counting both dates with the 30 day limitation, then you would need to change <= to <

As written the formula could also be expressed as

C1:  =if((A1+30)>=B1,"t","f")

This might be a clearer expression of your rule.

--
Regards,
Tom Ogilvy
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

#### Tom Ogilvy

##### Expertise

Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]

##### Experience

Extensive experience.

Education/Credentials
Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.