Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to compare the time entered to current time.

Status
Not open for further replies.

sknyppy

Programmer
May 14, 1999
137
US
The user selects an expiration time from a selectbox and then uses a radio button to select AM/PM.
The result looks like '3:30 PM'.

So I'm trying to compare 3:30 PM to 4:30 PM.

I need to compare the expiration time to the current time, if the current time is past the expiration time I need to delete it. I have a scheduled task that runs every 30 minutes checking for expired records.

How can I compare the times?
What datatypes do I need to use?
Any examples would be great!
 
If you are using VBS Date types then you can use the VBS function DateDiff(interval, date1, date2)

The interval is a string that lets the function know what you are trying to tell, i.e. days, minutes, months, etc. Normally you'd use one of the following:

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

You can use the CDate function to create a Date-type variable from a string.

MyDate = "October 19, 1962"
MyShortDate = CDate(MyDate) Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
Sorry, to clarify, you need to use the DateDiff function and use the minute interval to find the difference between minutes. When you use the now() function, it returns the current system date/time as a Date-type variable. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top