number of days between two dates in european format

  • Thread starter Thread starter manan
  • Start date Start date
M

manan

Hi

I was trying to calculate number of days between two dates. The dates
are in dd/mm/yyyy format. lets say in a1 31/03/2005 and in b1 its
28/02/2007. But when i try to put the formula =b1-a1 in c1 then its
throwing up #value error.
How do i rectify this.
Thanks in advance
 
If you are getting #VALUE, then perhaps A1 or B1 are actually text
values which just look like dates. Use Format | Cells | Number tab to
check - change if necessary, then edit the cell(s) with F2 to implement
the change. Alternatively, change the formula in C1 to this:

=VALUE(B1) - VALUE(A1)

Hope this helps.

Pete
 
Hello Manan,

Please find my example.
I hope it helps.

Sub DateDifference()
Dim FirstDate As Date ' Declare variables.
Dim SecondDate As Date
FirstDate = InputBox("Enter a date")
SecondDate = InputBox("Enter a date")
Msg = "Days from second day to first day: " & DateDiff("d", FirstDate,
SecondDate) & "," & _
vbCr & "Months: " & DateDiff("m", FirstDate, SecondDate) & "," &
_
vbCr & "Years: " & DateDiff("yyyy", FirstDate, SecondDate) & "."
MsgBox Msg

End Sub

Best Regards,

Agnieszka
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top