Writing Expressions : Manipulating string data : Converting a string to a date
 
Converting a string to a date
A data source sometimes stores dates as strings. Reports, however, typically need to sort, format, or manipulate these values as dates. For example, values of date type are sorted in date order, such as 2/18/2010, 2/19/2010, 2/20/2010, 2/21/2010 rather than in alphanumeric order, such as 2/18/2010, 2/19/2010, 2/2/2010, 2/20/2010. In addition, unlike date strings, you can manipulate values of date type mathematically, for example, calculate the difference between two dates.
To convert dates from string to date type, pass a supported date format to the JavaScript Date object, as shown in the following example:
var datestring = "01/15/2010"; //Variable with MM/dd/yyyy format
new Date(datestring); //Pass the date format to the Date object
JavaScript supports the following date formats for string to date conversions:
*MM/dd/yyyy (for example: 10/15/2010)
*MMMM dd, yyyy (for example: October 15, 2010)
*MMM dd, yyyy (for example: Oct 15, 2010)
*yyyy/MM/dd (for example: 2010/10/15)
If a data source stores dates as strings in one of those formats, the string to date conversion is simple. The following example converts values in the OrderDate field to the date type:
var datestring = row["OrderDate"];
new Date(datestring);