Click here to Skip to main content
15,303,151 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have in A1 = '20-05-2012' B1 = 'NO' and I want in C1 a formula to calculate the number of days between to dates, so:

string today = DateTime.Now;

   //Here I want that C1 = '3'
   //and tomorow will C1 = '4' 
   //because the number of days between 20-05-2012 and 23-05-2012 = 3
   //and tomorrow the number of days between 20-05-2012 and 24-05-2012 = 4

How I do this in excel?
I hope you understand my question...

Updated 23-May-12 6:36am

If you want highly efficient algorithms, then you want look at:[^]
I already solve it my friend:


this gives me the number of days between two dates:



But thanks!

Richard MacCutchan 24-May-12 4:31am
Why do you need to multiply by -1? What is wrong with TODAY()-D4?
Killzone DeathMan 24-May-12 4:37am
Because ('23-05-2012') - ('24-05-2012') = -1
and (-1)*(-1) = 1
I don't know why the result is -1, but multiply by -1 it works :)
Richard MacCutchan 24-May-12 4:42am
Like I said, why not just use TODAY()-D4?
Killzone DeathMan 24-May-12 4:49am
Because...because... come on my friend, it looks more mathematically...
But 'TODAY()-D4' and '(D4-TODAY())*-1' are the same! :)
Richard MacCutchan 24-May-12 4:54am
They are indeed the same in terms of the result, but why make a formula more complicated than it needs to be? Imaging some intern 5 years from now looking at that formula and wondering why it needs the 'extra' bit of calculation.
Killzone DeathMan 24-May-12 4:58am
ok ok I understand... I was just joking...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900