Work out Days Between Two Dates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Is there a way to workout days between two dates like networkdays in code.
any help will be much appreciated
Charles
 
Hi Charles,

One way:

Sub a()
Dim x As Long
Dim d1 As Long, d2 As Long
d1 = DateSerial(2000, 1, 1)
d2 = DateSerial(2002, 1, 1)
x = Application.Evaluate("=NETWORKDAYS(" & d1 & "," & d2 & ")")
Debug.Print x
End Sub

HTH

Peter Beach
 
Hi Charles,

One way:

Sub a()
Dim x As Long
Dim d1 As Long, d2 As Long
d1 = DateSerial(2000, 1, 1)
d2 = DateSerial(2002, 1, 1)
x = Application.Evaluate("=NETWORKDAYS(" & d1 & "," & d2 & ")")
Debug.Print x
End Sub

HTH

or, if you set a reference to atpvbaen.xls:

Sub a()
Dim x As Long
Dim d1 As Long, d2 As Long
d1 = DateSerial(2000, 1, 1)
d2 = DateSerial(2002, 1, 1)
x = NETWORKDAYS(d1, d2)
Debug.Print x
End Sub



--ron
 
Back
Top