Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am currently experiencing the following error --> Type mismatch. Value 19/5/2014 does not match type datetime in column index 3.

JavaScript
function drawVisualization(dataValues, chartTitle, columnNames, categoryCaption)
{
   if (dataValues.length < 1)
      return;

   var data = new google.visualization.DataTable();
   data.addColumn('string', columnNames.split(',')[0], 'Name');
   data.addColumn('number', columnNames.split(',')[1], 'Price');
   data.addColumn('string', columnNames.split(',')[2], 'Price Type');
   data.addColumn('datetime', columnNames.split(',')[3], 'Date');

   for (var i = 0; i < dataValues.length; i++)
   {
      var date = new Date(parseInt(dataValues[i].Date.substr(6), 10));

      //Convert variable to date value
      //var date = new Date(parseInt(dataValues[i].Date.substr(6), 10));
      //var date = new Date("2013/12/19");

      //Set the format of Date to dd/MM/yyyy
      var newDate = date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear();
      alert(newDate)

      data.addRow([dataValues[i].ColumnName, dataValues[i].Value, dataValues[i].Type, newDate]);
   }
}


I am little unsure, how to go about solving this issue. if someone could direct me in the right direction, please. many thanks.
Posted
Updated 20-May-14 10:05am
v2
Comments
Maciej Los 20-May-14 16:11pm    
Why?
Do not convert date to specific format! Date is a date, not a string!
miss786 20-May-14 16:29pm    
thank you for your feedback. My current format for dates is -- May 19, 2014, 12:00:00 AM. I would like to trim the time from the date, if possible. please advise. thanks

1 solution

Please, read my comment to the question.

Have a look here: Overview of Globalization and Localization[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900