Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21246

Time difference and time range

$
0
0
im trying to work on a some code that will start then stop something if the current time is within a certain range. i have searched this forum and found code using datediff and timeserial, below, but it all works as long as both the start and stop time are either am or pm. my problem is when say the start time is 5:30 pm and the stop time is 6:00 am. the database time is just a access time/date field in format 5:30:00 PM

if have tried this, but the am pm is an issue

Code:

Dim date1 As Date
Dim date2 As Date
    date1 = Format(rs2.Fields("BurnInOnTime").Value, "hh:mm:ss")
    date2 = Format(rs2.Fields("BurnInOffTime").Value, "hh:mm:ss")
   
    If DateDiff("n", date1, Time) >= 0 Then

        If DateDiff("n", date2, Time) < 0 Then

            Picture1.Visible = False ' blank out the picture box to display the all black full screen form
            Exit Sub

        End If
    End If


Viewing all articles
Browse latest Browse all 21246

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>