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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help about Time Check

Status
Not open for further replies.

Zahir

Programmer
Sep 16, 1999
28
PK
Hi..

i havee Start time and End time

like

start time : 4:00 PM
end time : 7:00 AM (next day )

i wana check my current time is it in between of the start time and end time . How it is possible, i need it urgent

Thanks u ppl

Regards
Zahir
 
Maybe this might help

I dont think you can just have a time - you will need a date and time

Start time = 31-07-02 16:00
End time = 01-08-02 07:00

You will have to check out the format for the variables

Then check if Now is >= StartTime and <= EndTime

Hope this puts you in the right direction
 
Give this a try:

Private Sub Command1_Click()
Dim dStart As Date
Dim dEnd As Date

dStart = Date & &quot; &quot; & #7:00:00 AM#
dEnd = DateAdd(&quot;d&quot;, 1, Date) & &quot; &quot; & #7:00:00 AM#
If dStart < Now And dEnd > Now Then
Print &quot;OK&quot;
Else
Print &quot;Not OK&quot;
End If
End Sub

Hope this helps. If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
Sorry I used different times than you are asking for should be

Private Sub Command1_Click()
Dim dStart As Date
Dim dEnd As Date

dStart = Date & &quot; &quot; & #4:00:00 PM#
dEnd = DateAdd(&quot;d&quot;, 1, Date) & &quot; &quot; & #7:00:00 AM#
If dStart < Now And dEnd > Now Then
Print &quot;OK&quot;
Else
Print &quot;Not OK&quot;
End If
End Sub
If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top