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 - Timer and Date Functions
plus

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

Check for valid time input from user


Posted: 06/25/98

Note: Use this script at your own risk....
This is un-tested code written by one of our users and
posted to the WebBoard "WinBatch script exchange" conference.

; CHKDATE.WBT
; ===========

; Check date demo.
; This code snippet verifies a given date by adding "nothing" (0 seconds)
; to it. If (and only if) an error occurs, the date is invalid.

sTitle="Check Date Demo"
nPrevErrMode=ErrorMode(@OFF)
dToday=TimeYmdHms()
dDate=AskLine(sTitle, "Please enter a date (YY:MM:DD:hh:mm:ss)", dToday)
dNothing="00:00:00:00:00:00"
LastError()
dDate2=TimeAdd(dDate, dNothing) ;<-- this line does all the work
If LastError()
   Message(sTitle, "Sorry, the date you entered is invalid !")
Else
   Message(sTitle, "Well that's my favorite date, too !")
EndIf
ErrorMode(nPrevErrMode)

Exit

Article ID:   W13861
Filename:   Check for valid time input from user.txt
File Created: 1999:04:15:16:56:52
Last Updated: 1999:04:15:16:56:52