DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   Multiple "OR" process (http://www.daniweb.com/forums/thread123865.html)

mgorecki May 12th, 2008 10:32 am
Multiple "OR" process
 
Hello,
I'm a newbie at VB and am trying to get some help with a process. My code will check an Excel file for dates and store them in a number of variables. Then I want to be able to compare those dates to the current date. I was thinking about using "Case", but is there a smoother, better way to do this? What I want is to basically say, "If any of these dates meet the criteria, then do something."

Thanks,
Mark

selvaganapathy May 12th, 2008 12:40 pm
Re: Multiple "OR" process
 
Hi
You can use DateDiff Function to Compare dates
DateDiff(interval, date1, date2)


Interval may be

yyyy -- Year
m - Month
y - Day of year
d - Day
w - Weekday
ww - Week
h - Hour
n - Minute
s - Second

Example

Dim TheDate As Date   ' Declare variables.
Dim Msg as String
TheDate = InputBox("Enter a date")
Msg = "Days from today: " & DateDiff("d", Now, TheDate)
MsgBox Msg


All times are GMT -4. The time now is 4:05 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC