function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kalle KalifKalle Kalif 

Google Annotated Timeline - DATE format issue

Hello people,

 

I am making a Google annotated timeline to put into my visualforce page. It is working fine in every way except for the fact that the format of the date field it extracts from salesforce is incompatible:

 

Type mismatch. Value 2011-06-23 does not match type date in column index 0

 

I believe the date has to be in the format of YYYY, MM, DD. Any ideas as to how i can change it over to this in my code?

 

 

 

Full VF page below:

<apex:page standardController="Vehicle__c">

<head>

<script type='text/javascript' src='https://www.google.com/jsapi' />
<script src="/soap/ajax/23.0/connection.js" type="text/javascript" />
<script type="text/javascript">

    google.load('visualization', '1', {'packages':['annotatedtimeline']});
    google.setOnLoadCallback(drawChart);
        sforce.connection.sessionId = '{!$Api.Session_ID}';

    function drawChart() {
        //table to act as the datasource for the timeline
        var data = new google.visualization.DataTable();
        data.addColumn('date', 'Date');
        data.addColumn('number', 'Fuel');

// Query data using SOQL.

var result = sforce.connection.query("Select day_only(report_date__c) Date, avg(Cons__c) Fuel From Report__c where Vehicle_name__c='{!vehicle__c.id}' group by day_only(report_date__c) order by day_only(report_date__c)");

// Iterate over the result
var it = new sforce.QueryResultIterator(result);
while(it.hasNext()) {
var record = it.next();
// Add the data to the table
data.addRow([record.Date, {v:parseFloat(record.Fuel)}]);
}

        var chart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div'));
        chart.draw(data, {displayAnnotations: true});
      }
    </script>
  </head>
  <body>
    // Note how you must specify the size of the container element explicitly!
    <div id='chart_div' style='width: 700px; height: 240px;'></div>
  </body>
</apex:page>

 

sekharasekhara

 Try this and let me know if it works r not..

 

 

<apex:outputText value="{0,date,yyyy'/'MM'/'dd}">

<apex:param value="{!userInputAppointment.Appt_Date__c}”/>

  </apex:outputText>

 

Kalle KalifKalle Kalif

I cannot get that to work. Not sure if its possible since iam not using a controller but ajax toolkit to access data?