WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Time UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Check Between Two Times UDF

 Keywords:  Checks certain time between 2 times

Checks if a certain time is between 2 times.

;***************************************************************************
;* FUNCTION : F_IsCurrentTimeBetween 
;* DATE : 22 mei 2002 
;* PURPOSE : Checks if a certain time is between 2 times
;* AUTHOR : T. Coolen 
;* VERSION : 1.00 
;* INPUT : Computertimes like 2002:05:27:09:38:24 
;* RETURNS : @TRUE if so, @FALSE when not
;* CATAGORY : Universal function 
;***************************************************************************
#DefineFunction F_IsCurrentTimeBetween(StartTime,EndTime)
; VStartTime="09:47:00" ;
; VEndTime ="12:00:00" ;
Answer = @FALSE
LenStarttime = 0
LenEndTime = 0
NStarttime = TimeYmdHms() ; create time vars
NEndTime = TimeYmdHms() ; create time vars
LenStartTime = Strlen(StartTime)
LenEndTime = StrLen(EndTime)


if LenStartTime<8 then Message("ERROR","Wrong input expecting format HH:MM:SS!")
if LenEndTime<8 then Message("ERROR","Wrong input expecting format HH:MM:SS!")

Now = TimeYmdHms( ) ; Get current time
YYMMDD = strsub(now,1,strlen(Now)-8) ; Get current year month and date
NStartTime = strcat(YYMMDD,startTime) ; Compose valid StartTime
NEndTime = strcat(YYMMDD,EndTime) ; Compose valid EndTime

if Now>=NStartTime 
If Now<=NEndtime 
Answer=@TRUE
;message("","Now=%Now% is between %NStartTime% and %NEndTime%!")
Endif
Endif
return Answer
#EndFunction
;*******************************************************************
;***** End of function F_IsCurrentTimeBetween 
;*******************************************************************


Article ID:   W15766
File Created: 2003:05:13:11:29:58
Last Updated: 2003:05:13:11:29:58