VB-Scripting CDate v/s IsDate function – User friendly Tech help
Function Name:- Cdate
n
nMeaning :- Returns expression in the form of variant date.n
Syntax:- Cdate(date)
n
- n
- date argument should be valid date format
- CDate recognizes date formats according to the locale setting of your system.
n
n
n
Function Name:- IsDate
n
nMeaning :- Returns Boolean value, telling whether date conversion of expression is possible or not
n
nSyntax:- IsDate(expression)
n
- n
- Returns “True” incase conversion is possible , else returns “False”
n
n
Example:-
n
n
- n
- Dim sDate,sTime ‘Delcaring Variables
- sDate = “May 22, 2013” ‘Delcaring Date
- MsgBox CDATE(sDate) ‘Returns Date As per your local system date Format
- MsgBox ISDATE(sDate) ‘Returns “True”
- sTime=”22:14:12PM” ‘Declaring Time
- MsgBox CDATE(sTime) ‘Returns time as per your local system timing format
- MsgBox ISDATE(sTime) ‘Reurns “True”
- sDate = “UFTHelp” ‘Passing invalid dates
- MsgBox ISDATE(sDate) ‘Returns “False”
- MsgBox CDATE(sDate) ‘Returns Runtime error
n
n
n
n
n
n
n
n
n
n