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
  • n

  • CDate recognizes date formats according to the locale setting of your system.
  • 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
  • n

  • sDate = “May 22, 2013” ‘Delcaring Date 
  • n

  • MsgBox CDATE(sDate) ‘Returns Date As per your local system date Format
  • n

  •  MsgBox ISDATE(sDate) ‘Returns “True” 
  • n

  • sTime=”22:14:12PM” ‘Declaring Time 
  • n

  • MsgBox CDATE(sTime) ‘Returns time as per your local system timing format 
  • n

  • MsgBox ISDATE(sTime) ‘Reurns “True” 
  • n

  • sDate = “UFTHelp” ‘Passing invalid dates 
  • n

  • MsgBox ISDATE(sDate) ‘Returns “False”
  • n

  • MsgBox CDATE(sDate) ‘Returns Runtime error
  • n

Was this article helpful?
YesNo

Similar Posts