MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Whats the formula to find the amount of days between 2 dates using VB 5.0?

Posted by Andres on March 26, 2001 12:59 PM

If u know or have a small sample of the program, could
u plz send it to me by e-mail, that would be thankfull,
or if u dont have a sample, but know what the formula
is, plz post it, tnx.

Posted by mseyf on March 26, 2001 2:48 PM

one possible solution:

Sub DateDiff()

Dim Date1 As Date
Dim Date2 As Date
Dim Diff As Date

Date1 = #1/1/01#
Date2 = #12/31/01#
Diff = Date2 - Date1
MsgBox CInt(Diff)

End Sub

Posted by Dave Hawley on March 27, 2001 1:30 PM

Not sure if this is an option for you:

Dim Date1 As Date, Date2 As Date
Date1 = Date
Date2 = Date + 5
MsgBox DateDiff("d", Date1, Date2)

OzGrid Business Applications