VBScript CDate() Function
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/2020
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
Last Updated :
20 Oct, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...