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 function

Status
Not open for further replies.

kitnba

MIS
Jul 31, 2000
132
HK
How can I calculate the date?
example : a=01/08/2003
b=02/08/2003

I want to know how to get the result b-a = 1 days?
what function I can use in Excel to get it?

Thanks
 
Paste the following into a standard code module: -


Function difference(value1 As Date, value2 As Date) As Integer

difference = DateDiff("d", value2, value1)

End Function

To use insert the following into a cell

=difference(datevalue 1, datevalue 2)

where datevalue is te date you wish to find the difference for
 
Or just = B - A

Dates are held as numbers in excel - and 1 day = 1
Therefore 1 hour = 1/24 etc etc so B-A will give you your answer in days

Rgds, Geoff
Si hoc legere scis, nimis eruditionis habes
Want the best answers to your questions ? - then read me baby one more time - faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top