Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default VBA: Date Comparison

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default VBA: Date Comparison

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default VBA: Date Comparison

Thank you! I have implemented it and it works.

"Ingolf" wrote:

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Comparison Vic Excel Discussion (Misc queries) 1 October 22nd 09 03:18 PM
date comparison oldLearner57 Excel Discussion (Misc queries) 2 March 29th 09 04:45 PM
Date comparison adimar Excel Worksheet Functions 14 February 3rd 08 06:44 PM
date comparison help CathyZ Excel Discussion (Misc queries) 5 May 4th 06 11:53 AM
Date comparison Darkdrew Excel Worksheet Functions 7 March 23rd 06 04:22 PM


All times are GMT +1. The time now is 09:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"