Promotic
WikipediaLinkedInYoutubeTwitterFacebook

CDate - function of language VBScript

Description:
Returns an expression that has been converted to type Date.
Syntax:
CDate(expression As Variant) As Date
Calling:
d = CDate(expression)
Parameters:
expression(Variant) date or string expression, that represents a date or time
Note:

CDate recognizes date literals and time literals as well as some numbers that fall within the range of acceptable dates. When converting a number to a date, the whole number portion is converted to a date. Any fractional part of the number is converted to a time of day, starting at midnight.

CDate recognizes date formats depending on the locale setting of Windows system. The correct order of day, month, and year may not be determined if it is provided in a format other than one of the recognized date settings. In addition, a long date format is not recognized if it also contains the day of the week string.

Use the IsDate function to determine if date can be converted to a date or time.

Example:
VBScriptSelect and copy to clipboard

Dim sDate, tShortDate, sTime, tShortTime
sDate = "October 19, 2018"
tShortDate = CDate(sDate)
sTime = "4:35:47 PM"
tShortTime = CDate(sTime)
PROMOTIC 9.0.0 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice