Time Function

  • Thread starter Thread starter Bob Quintal
  • Start date Start date
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
 
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
 
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.
 
Oops, sorry, that should be

If Time() < #08:30:00# Or _
Time() > #17:30:00# Then
Exit Sub
End If
 
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.
 
What gets displayed between the # delimiters will be impacted by how your
Time format has been set through Regional Settings in the Control Panel.
 
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.
 
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
 
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
 
Back
Top