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

Time between

Status
Not open for further replies.

Leighton21

Technical User
Dec 17, 2001
83
AU
Hi All,

Probably an easy one. However here goes given a specific time (configured as 24 hour format and without the date portion). Is it possible (without the date) to see if the time falls within a specified start and end time i.e. given 0500 need to return true if it is between 1700 and 0600 i.e. 5pm today and 6am tommorow (bare in mind there is no date)

Cheers
 
It will be something along these lines
Code:
<job>
<script language="vbscript">
lo = cdate("06:00")
hi = cdate("17:00")
testfalse = cdate("05:00")
testtrue = cdate("12:00")
between = testfalse >= lo and testfalse <= hi
WScript.echo cstr(testfalse) & " between " & cstr(lo) & " and " & cstr(hi) & "=" & cstr(between)
between = testtrue >= lo and testtrue <= hi
WScript.echo cstr(testtrue) & " between " & cstr(lo) & " and " & cstr(hi) & "=" & cstr(between)
</script>
</job>
Since you don't really care about days, not between 0600 and 1700 is the same as less than 0600 or greater than 1700.

cdate is used for both date and time.
 
Cheers XWB

What would happen though if the lo and hi went across two days i.e. the lo was 17:00 and the hi was 00:05

Thanks in advance
 
lo will always be the lower number i.e. 00:05 and hi will always be the higher number i.e. 17:00. If you stick them in that order then it will work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top