DateTime on XAxis - ToOADate?

Thread is closed for posting
3 posts, 1 answers
  1. Chris
    Chris avatar
    16 posts
    Member since:
    Apr 2008

    Posted 22 Apr 2008 Link to this post

    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. Answer
    Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 23 Apr 2008 Link to this post

    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
  3. Chris
    Chris avatar
    16 posts
    Member since:
    Apr 2008

    Posted 24 Apr 2008 Link to this post

    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
Back to Top