How To Convert String to Date Using ASP

ASP makes it very easy to convert a string to a date format using built-in VBScript functionality. We're going to use the CDate function to accomplish this. The CDate function has one argument, which is the text to be converted to date format.

Here's how to do it:

  1. Open up your text editor and type the following piece of code:


    Dim MyDate

    MyDate = "April 12, 1978"


  2. Now, use the function this way to convert the date, and print the new format to the screen:


    Response.Write CDate(MyDate)


The result will be displayed in your browser like this:



Share this article!

Follow us!

Find more helpful articles: