;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfIsValidDateTime (strYmdHms) intLastErrorMode = ErrorMode (@OFF) LastError () TimeDiff (strYmdHms, strYmdHms) ErrorMode (intLastErrorMode) Return !LastError () ;.......................................................................................................................................... ; This user defined function "udfIsValidDateTime" checks a given WinBatch ; Date string e. g. "2009:02:01" or DateTime string e. g. "2009:02:01:08:00:00" ; wether it is valid or not. ; The function returns a boolean value of @FALSE (0) or @TRUE (1). ; ; Detlev Dalitz.20010325.20090724. ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ; Test. blnResult11 = udfIsValidDateTime (TimeYmdHms ()) ; @TRUE. blnResult12 = udfIsValidDateTime ("2009:02:01") ; @TRUE. blnResult13 = udfIsValidDateTime ("2009:02:01:23:59:59") ; @TRUE. blnResult14 = udfIsValidDateTime ("2009:02:02:00:00:00") ; @TRUE. blnResult15 = udfIsValidDateTime ("2009:2:1") ; @TRUE. blnResult16 = udfIsValidDateTime ("2009:2:1:0:0:0") ; @TRUE. blnResult21 = udfIsValidDateTime ("0:1:1:0:0:0") ; @TRUE. Minimum DateTime. blnResult22 = udfIsValidDateTime ("9999:12:31:23:59:59") ; @TRUE. Maximum DateTime. blnResult31 = udfIsValidDateTime ("2009:02:01:00:00:60") ; @FALSE. blnResult32 = udfIsValidDateTime ("2009:02:01:00:60:00") ; @FALSE. blnResult33 = udfIsValidDateTime ("2009:02:01:24:00:00") ; @FALSE. blnResult34 = udfIsValidDateTime ("2009:02:00:00:00:00") ; @FALSE. blnResult35 = udfIsValidDateTime ("2009:00:01:00:00:00") ; @FALSE. blnResult36 = udfIsValidDateTime ("2009:01:32:00:00:00") ; @FALSE. blnResult37 = udfIsValidDateTime ("2009:02:29:00:00:00") ; @FALSE. blnResult38 = udfIsValidDateTime ("2008:02:29:00:00:00") ; @TRUE. Leap-day. blnResult39 = udfIsValidDateTime ("2008:02:30:00:00:00") ; @FALSE. blnResult41 = udfIsValidDateTime ("2009:02:01:::") ; @FALSE. blnResult42 = udfIsValidDateTime ("2009:2:1:::") ; @FALSE. blnResult51 = udfIsValidDateTime ("1600:02:29:00:00:00") ; @TRUE. blnResult52 = udfIsValidDateTime ("1700:02:29:00:00:00") ; @FALSE. blnResult53 = udfIsValidDateTime ("1800:02:29:00:00:00") ; @FALSE. blnResult54 = udfIsValidDateTime ("1900:02:29:00:00:00") ; @FALSE. blnResult55 = udfIsValidDateTime ("2000:02:29:00:00:00") ; @TRUE. blnResult56 = udfIsValidDateTime ("2100:02:29:00:00:00") ; @FALSE. blnResult57 = udfIsValidDateTime ("2200:02:29:00:00:00") ; @FALSE. blnResult58 = udfIsValidDateTime ("2300:02:29:00:00:00") ; @FALSE. blnResult59 = udfIsValidDateTime ("2400:02:29:00:00:00") ; @TRUE. blnResult61 = udfIsValidDateTime ("4000:02:29:00:00:00") ; @TRUE. blnResult62 = udfIsValidDateTime ("8000:02:29:00:00:00") ; @TRUE. Exit