VBS TUTORIAL: function-cdate function _vbs

Source: Internet
Author: User
Tags time and date

CDate function

Returns an expression that has been converted to a Variantof the Date subtype.

CDate(date)

The date parameter is any valid datetime expression.

Description

The IsDate function is used to determine whether date can be converted to a date or time. CDate recognizes date and time literals, as well as some numbers within an acceptable date range. When you convert a number to a date, the integer portion of the number is converted to a date, and the fractional portion is converted to the time calculated from midnight.

CDate The date format according to the locale settings of the system. If the format of the data cannot be identified by the date setting, the correct order of year, month, and day cannot be judged. In addition, if the long date format contains a string that represents the day of the week, it cannot be recognized.

The following example uses the CDate function to convert a string to a date type. It is generally not recommended to use hardware decoding dates and times as strings (as shown in the following example). Use time and date literals (such as #10/19/1962#, #4:45:23 pm#).

  mydate = "October, 1962         "  defines the date.  myshortdate =   CDate ( mydate )              '  to the date data type.  mytime = "4:35:47 PM"          '  defines the time.  myshorttime =   CDate ( mytime )              '  to the date data type. 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.