Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Difference in Execl 2

Status
Not open for further replies.

dipgohil79

Programmer
Jun 14, 2002
17
IN
Hi to all,
In MS Excel there is a function Call Days360, which gives the difference bitween two dates.but the problem is it count year as 360 days. I want the real calculation that is 365 for normal year and 366 for leapyear.
I am very new in VBA. so i need help for this.
 
Dates are stored as integers. So all you need is End Date - Start Date

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
@anotherhiggins
thanks for quick response. but while testing when i use following this two dates 1-Nov-08 and 12-Nov-08 some time i got result 11 and some time i got result 11-Jan-00.

I am confuse about this.
 
[blue][tt]11[/tt][/blue] and [blue][tt]11-Jan-00[/tt][/blue] are just different ways of formatting the same underlying value. Format your result cell as a number - instead of as a date - and you will get [blue][tt]11[/tt][/blue].

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
If you remove the date format on the cells containing the dates and impose number format you will see 01/11/2008 change into 39753 and 12/11/2008 change into 38764; these numbers represent the number of days since 31 Dec 1899 which Excel uses as a reference.
When you subtract the dates Excel computes the difference between the two 'day numbers' and gives you 11 however it is in appropriate to apply a date format to this result because the format will only return a date equal to eleven days after 31 Dec 1899. If you require a result formatted in years, months, days you will have to do that yourself.

 
Thanks "TonyJollans" and "anotherhiggins" for your respons.

you people are great, just do what you are doing - helping the others
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top