VBA: Date Comparison

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

Guest

In VBA, I want to compare an input date (mm/dd/yy) with the current system
date and return either positive (input date prior to current date) or
negative (input date precedes current date) days.
 
Hi,

'declare variables
Dim dat As Date
Dim days As Integer
'enter date as text, change to date format and save in variable dat
dat = CDate(InputBox("Enter Date (mm/dd/yy)"))
'subtract entered date from systemdate and save result in variable days
days = Date - dat

Regards
Ingolf
 
Back
Top