Skip to content
Related Articles

Related Articles

VBScript CDate() Function
  • Last Updated : 22 Feb, 2021

The VBScript CDate Function is used to convert a valid date and time expression to type Date. It returns the correct order of dates. It recognizes date formats according to the locale setting of your system.

Note: We can also use the IsDate function to determine if date can be converted to a date or time.

Syntax:

CDate(date)

Parameter: This function accepts a single a parameter as mentioned above and described below.

  • date: It is a required attribute. It specify any valid date expression.

Example 1: Below examples illustrates the VBScript CDate Function.



VBScript




<%
  gfg=CDate("May 6, 2020")
  response.write(gfg)
%>

Output:

5/6/202

Example 2: Below code illustrates that how to convert numbers with separators to a date:

VBScript




<%
  gfg=CDate(#4/22/10#)
  response.write(gfg)
%>

Output:

4/22/2010
My Personal Notes arrow_drop_up
Recommended Articles
Page :