Penn State junior
The world's only r
Recommended Readin
The World Trade Or
This is a new appl
Q: WCF, is it pos
On September 20, 2
Inhibiting P2X4 re
--- abstract: 'The
C. V. Meenakshi Su

Invasive Species
In many parts of t
1. Field of the In
/* SPDX-License-Id
FORT COLLINS, Colo
AUSTIN — After the
Wheat quality para
/* $OpenBSD: pwd_t
Gigapans An artis
Gastric varices: p
Q: How do I change this formula to display the number of days between now and a cell with a date? I have a formula for the number of days left in the week, with the first row being "today". =INT((B9-1)/7) I'm trying to use this same formula for the number of days in any given date. Let's say a cell with "6/20/13" I can use the DATE function and the format for the day (mmddyyyy) to figure out the date, but when I put it all together in a formula it's not correct. The closest I've come is by using the number from cell B9 and subtracting one day, but then it displays a #NUM! error. What am I missing? A: The "int" function in excel (I assume this is what you are using) uses the system settings as a reference for number formatting. I believe you need to enter the date as a text format (mm/dd/yyyy) and you can use a standard date function to convert it to a real number. Do this instead: =DAYS(NOW(),DATEVALUE(C1)) This assumes that the number entered in C1 is a valid date (i.e. something like 2/1/2016 is not considered a valid date by excel) If you just have text, you need to do a bit more work: =IF(TEXT(C1,"m/d/yyyy")="",INT(B9-1)/7,DAYS(NOW(),DATEVALUE(TEXT(C1,"m/d/yyyy")))) The trick to this is to convert the string into a date, then use the DATEVALUE function. This can be a pain if you aren't sure what the text will be (it needs to be a date in order to convert properly). A: Excel's "INT" function needs a date and a number to work. So, you have to use formulas. You have to subtract one day from the cell containing the date you want to convert to a number. So let's say that cell is E5, then you would enter the formula: =INT(E5-1) The result would be the number of days. A: Use the DateDif function from a standard module: Function Datediff( _ startDate As Date, _ endDate As Date, _ Optional weekdays As Variant = 1, _ Optional month As Variant = 0, _ Optional year As Variant = 0, _ Optional firstweekday As Variant = 0, _ Optional lastweekday As Variant = 0 _ ) As Long Dim dateDiff As Long Dim d1 As Date Dim d2 As Date d1 = dateValue(startDate) ' convert start date to Date object d2 = dateValue(endDate) ' convert end date to Date object dateDiff = DateDiff(weekdays + month + year, d1, d2) If weekdays > 0 Then If firstweekday > 0 Then dateDiff -= (dateDiff / 7 * firstweekday) Else dateDiff -= (dateDiff / 7 * firstweekday) + (dateDiff Mod 7) End If End If If month > 0 Then dateDiff += (dateDiff / 12 * (1 + month)) End If If year > 0 Then dateDiff += (dateDiff / 365 * year) End If dateDiff = dateDiff \ 1 ' Excel VBA doesn't return fraction of days dateDiff = Abs(dateDiff) ' Excel VBA doesn't return negative days If dateDiff > 0 Then ' don't count negative dates dateDiff = dateDiff + 1 Else dateDiff = 0 End If End Function It uses the DateDif VBA function (also from a standard module). It uses some work arounds to get around quirks in Excel's VBA date functions, it should work for your usage as well. To find the difference between two dates in days in Excel, you may need to use some work arounds. For example, if you put 4/6/2013 into cell A1 and 6/5/2013 into B1, and then do =Datediff(B1, A1, 0, 1, 0, 1) it gives you -1 (because 6/6/2013 minus 4/6/2013 is -2). This happens because Excel's DATEDIFF function does not know how to handle leap years. If the first date is not a leap year and the second date is, DATEDIFF gives you 1 extra day. You would have to use the Excel's work around to get Excel to give you the correct number. You can either do it by add 1 to the result you get from DATEDIFF =INT(A1 - DATEDIFF(A1, B1, 0, 1, 0, 1)) add 1 to the result you get from DATEDIFF =INT(DATEDIFF(A1, B1, 0, 1, 0, 1)) + 1 convert the values to decimal =(A1 - B1)*365 + (A1 - B1) / 4 / 4 + (A1 - B1) - MOD(A1 - B1, 4) * 14 - MOD(A1 - B1, 4) / 4 / 4 - MOD(A1 - B1, 4) + MOD(A1 - B1, 100) + MOD(A1 - B1, 400) + MOD(A1 - B1, 4) - MOD(A1 - B1, 100) / 100 add 1 if the year is a leap year =INT(DATEDIFF(A1, B1, 0, 1, 0, 1) + IF(MOD(A1 - B1, 4) = 0, 1, 0)) There are many similar workarounds, all of which can be found here: http://www.mrexcel.com/forum/excel-questions/90533-excel-difference-between-two-dates-leap-year-or-not.html The above functions use Excel 2007 VBA Language and Calendar functions.