This is a migrated thread and some comments may be shown as answers.

DateTime on XAxis - ToOADate?

2 Answers 203 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 22 Apr 2008, 09:40 PM
Hello,

I am trying to bind a simple data source to a line series chart control, and I'm having a lot of difficulties getting the DateTime field to work.   The stored procedure is very simple and returns a DateTime column and an int column that I want to chart on the Y axis.

From what I can gather the chart control needs dates in the OLE Automation date/time format?  How do I do this for a data bound chart?  I found this example:
http://www.telerik.com/help/RadChart/v3_NET2/?chrtSetCustomXAxisYAxis%20items.html

but it only shows you how to do this programatically with fixed dates.  Is there anything I can do to convert the DateTime field in SQL in my stored procedure in a format that the chart control understands?

Thanks!

Chris

2 Answers, 1 is accepted

Sort by
0
Accepted
Giuseppe
Telerik team
answered on 23 Apr 2008, 07:02 AM
Hi Chris,

You can use the following SQL cast to pass the DateTime value in the numeric format that can be handled by the RadChart control:

SELECT  
     [balance],   
     [as_of_date],   
     CAST(as_of_date AS FLOAT) + 2 as float_date   
FROM  
     [Balance] 


Hope this helps.


Greetings,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Chris
Top achievements
Rank 1
answered on 24 Apr 2008, 05:43 PM
Thanks!!  That worked great - at first the dates were all coming through as the year 1899 when I first tried this, but I found out that I had to change the IsZeroBased property to false, and the dates started coming through as expected.

Thanks!

Chris
Tags
Chart (Obsolete)
Asked by
Chris
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Chris
Top achievements
Rank 1
Share this question
or