Tuesday, July 1, 2014

QTP Functions-Part 2


CDate Function:

Returns an expression that has been converted to a variant of subtype Date.

Syntax:

CDate (date)

date-any valid date expression

CDate() function uses IsDate() function to check if date can be converted to a date or time.
CDate recognizes date formats according to the locale setting of your system.

Example:

Dim strDate,strDate1,strTime,strTime1

strDate="April 10, 2010" 'Define Date

strDate1=CDate(strDate)     'Convert to Date datetype

strTime="2:30:45 AM"     'Define Time

strTime1=CDate(strTime)  'Convert to Date datetype

msgbox "Date : "&strDate1&", Time : "&strTime1


Output:

No comments:

Post a Comment