VBScript CDate function
CDate function to valid date and time expression into a date (Date) type, and returns the result. p>
Tip: Use theIsDate function to determine if date can be converted to a date or time.
Note: IsDate function uses local setting to detect whether a string can be converted to a date (in all languages, "January" is not a month).
grammar
CDate(date)
参数 | 描述 |
---|---|
date | 必需。任何有效的日期表达式(比如 Date() 或者 Now())。 |
Examples
Example 1
How to convert a string to a date:
<script type="text/vbscript">
d=CDate("April 22, 2010")
</script>
d=CDate("April 22, 2010")
</script>
try it"
Example 2
How delimited numbers into a date:
<script type="text/vbscript">
d=CDate(#4/22/10#)
</script>
d=CDate(#4/22/10#)
</script>
try it"
Example 3
How CDATE to convert the string to a Date object:
<script type="text/vbscript">
d=CDate("3:18:40 AM")
</script>
d=CDate("3:18:40 AM")
</script>
try it"
Complete VBScript Reference