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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top