Thank you so much for your advice and help.  I have added parse code in 
javascript but I am still experiencing - Type mismatch. Value 16/1/2013 
does not match type datetime in column index 3- error

This is what I have so far:

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

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



        for (var i = 0; i < dataValues.length; i++) {

            //var dateTimeString = "\/Date(1358294400000)\/";
            //var dateTime = new 
Date(parseInt(dateTimeString.split("/"[\(\)]/)[3]));

            //var date = new Date(parseInt(dataValues[i].Date.substr(6), 
10));

           //alert(dataValues[i].Date);

            var dateString = dataValues[i].Date.substr(6);
            var currentTime = new Date(parseInt(dateString));
            var month = currentTime.getMonth() + 1;
            var day = currentTime.getDate();
            var year = currentTime.getFullYear();
            var date = day + "/" + month + "/" + year;

           
            //var date = new Date(parseInt(jsonDate.substr(6)));
            //var date = new Date(new 
Number(jsonDate.replace(/(^.*\()|([+-].*$)/g, '')));
            //var date = eval(jsonDate.replace(/\/Date\((\d+)\)\//gi, "new 
Date($1)"));
            alert(date);

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

*code behind - [web method] - C#*


protected void Page_Load(object sender, EventArgs e)
    {

        JavaScriptSerializer jss = new JavaScriptSerializer();

        ClientScript.RegisterStartupScript(this.GetType(), 
"TestInitPageScript",
        string.Format("<script 
type=\"text/javascript\">google.load('visualization','1.0',{{'packages':['corechart','controls']}});google.setOnLoadCallback(function(){{drawVisualization({0},'{1}','{2}','{3}');}});</script>",
        jss.Serialize(GetData()),
        "Text Example",
        "Text Example",
         "Price_Type,"));

    }

    [WebMethod]
    public static List<test> GetData()
    {
        SqlConnection conn = new SqlConnection("########");
        DataSet ds = new DataSet();
        DataTable dt = new DataTable();
        conn.Open();
        var yesterday = DateTime.Today.AddDays(-1);
        string cmdstr = "select top 10 Name, [Decimal price],Cover, 
UploadDate from [dbo].[database]";
        SqlCommand cmd = new SqlCommand(cmdstr, conn);
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        adp.Fill(ds);
        dt = ds.Tables[0];
        List<test> dataList = new List<test>();
        string cat = "";
        float val = 0;
        string typ = "";
        DateTime dat = DateTime.Now.Date;
        //DateTime dat = new DateTime();

        //dat = DateTime.ParseExact("yyyyMMddHHmmss", 
CultureInfo.InvariantCulture);
        //var dtt = dat.ToShortDateString();
       // var dtt = DateTime.ParseExact(dat, "dd/MM/yyyy", null);

       // DateTime dat = DateTime.Now.Date;

        foreach (DataRow dr in dt.Rows)
        {
            try
            {
                cat = dr[0].ToString();

                val = Convert.ToInt32(dr[1]);

                typ = dr[2].ToString();

                //dat = (DateTime)(dr[3]);
                dat = (DateTime)(dr[3]);
                //dtt = dr[3].ToString();

            }
            catch
            {
            }
            dataList.Add(new test(cat, val, typ, dat));
        }
        return dataList;
    }

Any advice or help would be very helpful. Many thanks for your time and 
support.

>
>>>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to