Time Function

B

Bob Quintal

Good day,

I am trying to code for the following:

If the current time of day is less than 8:30 am and greater
than 5:30 pm, exit sub.


Please help. Thanks


Use the timer function to return the number of seconds since
midnight

dim starttime as single
dim enddtime as single
starttime = 60*60*8.5 ' secs/min * mins/hr * 8 & half hours
endtime = 60*60*17.5

.. If timer >= starttime and timer < enddtime then
exit sub
end if
 
G

Guest

Good day,

I am trying to code for the following:

If the current time of day is less than 8:30 am and greater than 5:30 pm,
exit sub.


Please help. Thanks
 
G

Guest

Sorry, that is what I meant. Code for less than 8:30 am Or greather than
5:30 pm. Could you post that again please.
 
D

Douglas J. Steele

Oops, sorry, that should be

If Time() < #08:30:00# Or _
Time() > #17:30:00# Then
Exit Sub
End If
 
G

Guest

Ahh, that did the trick. Very odd, I copy and pasted what you put in, and
access changed it to:

If Time() < #8:30:00 AM# Or _
Time() > #5:30:00 PM# Then
Exit Sub
End If

But is works.
 
D

Douglas J. Steele

What gets displayed between the # delimiters will be impacted by how your
Time format has been set through Regional Settings in the Control Panel.
 
G

Guest

Well thank you, that worked great.


Douglas J. Steele said:
What gets displayed between the # delimiters will be impacted by how your
Time format has been set through Regional Settings in the Control Panel.
 
M

Marshall Barton

Steve said:
If the current time of day is less than 8:30 am and greater than 5:30 pm,
exit sub.


If you are looking to check if the current tome is outside
that interval, use:

If Not (Time >= #8:30# And Time <= #17:30#) Then Exit Sub
 
B

Bob Quintal

OOPS. Forgot an else statement to invert the logic.

Use the timer function to return the number of seconds since
midnight

dim starttime as single
dim enddtime as single
starttime = 60*60*8.5 ' secs/min * mins/hr * 8 & half hours
endtime = 60*60*17.5

. If timer >= starttime and timer < enddtime then ELSE
exit sub
end if
 

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

Top