<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Axis.LabelFormat doesn't convert double to DateTime correctly in Measurement Studio for .NET Languages</title>
    <link>https://ni.lithium.com/t5/Measurement-Studio-for-NET/Axis-LabelFormat-doesn-t-convert-double-to-DateTime-correctly/m-p/131413#M481</link>
    <description>The Measurement Studio .NET graphs do not use OLE Automation (the OA in From/ToOADate) dates for the conversion factor between DateTime and double.  OA date was natural for the ActiveX controls in Measurement Studio 6.0 since they are COM components, but there is not a precedent in .NET for what the double representation of a DateTime should be other than From/ToOADate, which are really convenience methods for interop with COM interfaces.&lt;BR /&gt;&lt;BR /&gt;The DateTime/double conversion factor that the Measurement Studio graphs use is a double value of 0.0 is equivalent to DateTime.MinValue and a double interval of 1.0 is equivalent to 1 second.  The NationalInstruments.DataConverter class will convert from/to double and DateTime and TimeSpan with this conversion factor.  F&lt;BR /&gt;or example, to convert a DateTime to a double as in your example above, you could do this:&lt;BR /&gt;&lt;BR /&gt;    DateTime rtime = Convert.ToDateTime(dRow["result_time"]);&lt;BR /&gt;    xData[i] = (double)DataConverter.Convert(rtTime, typeof(double));&lt;BR /&gt;&lt;BR /&gt;DataConverter will also convert arrays of DateTime to double, like this:&lt;BR /&gt;&lt;BR /&gt;    DataTime[] rtimes;&lt;BR /&gt;    // Initialize rtimes with an array of DateTime values.&lt;BR /&gt;    xData = (double[])DataConverter.Convert(rtimes, typeof(double[])); &lt;BR /&gt;&lt;BR /&gt;I will file a suggestion to improve the documentation regarding this conversion and its use with the graph in a future release.&lt;BR /&gt;&lt;BR /&gt;Also, you may want to look at using the WaveformGraph instead of the ScatterGraph.  The WaveformGraph and WaveformPlot plot methods have overloads for specifying DateTime and TimeSpan values for the start and increment.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;- Elton &lt;BR /&gt;</description>
    <pubDate>Tue, 04 May 2004 19:23:33 GMT</pubDate>
    <dc:creator>Elton Wells</dc:creator>
    <dc:date>2004-05-04T19:23:33Z</dc:date>
    <item>
      <title>Axis.LabelFormat doesn't convert double to DateTime correctly</title>
      <link>https://ni.lithium.com/t5/Measurement-Studio-for-NET/Axis-LabelFormat-doesn-t-convert-double-to-DateTime-correctly/m-p/131412#M480</link>
      <description>I just want the time of my samples to appear on the x axis of plots I am creating with Measurement Studio 7.0 and C#.Net.&lt;BR /&gt;&lt;BR /&gt;I am creating a ScatterPlot and filling it with the PlotXY(double[] xData, double[] yData) method.  The xaxis is a set of Dates brought in from a database as strings and converted to standard DateTime objects:&lt;BR /&gt;&lt;BR /&gt;DateTime rtime = Convert.ToDateTime(dRow["result_time"]);&lt;BR /&gt;&lt;BR /&gt;I then fill the xData with this DataTime converted to a double, as that is all PlotXY will accept:&lt;BR /&gt;&lt;BR /&gt;xData[i] = rtime.ToOADate();   &lt;BR /&gt;&lt;BR /&gt;Note: This worked fine using the ActiveX components of Measurement Studio 6.0, but fails when using the new .Net components in MStudio 7.0.  &lt;BR /&gt;&lt;BR /&gt;I go into the XAxis Properties and&lt;BR /&gt; change my MajorDivisions.LabelFormat to a DateTime format such as "M/d/yy h:mm" and all I get are bogus dates such as 1/1/00 10:31 when it should be 9/23/03 12:05&lt;BR /&gt;&lt;BR /&gt;Please advise on how to convert DateTime to a double such that the Axis formatting will be correct. &lt;BR /&gt;</description>
      <pubDate>Tue, 04 May 2004 18:31:08 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/Measurement-Studio-for-NET/Axis-LabelFormat-doesn-t-convert-double-to-DateTime-correctly/m-p/131412#M480</guid>
      <dc:creator>mturon</dc:creator>
      <dc:date>2004-05-04T18:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Axis.LabelFormat doesn't convert double to DateTime correctly</title>
      <link>https://ni.lithium.com/t5/Measurement-Studio-for-NET/Axis-LabelFormat-doesn-t-convert-double-to-DateTime-correctly/m-p/131413#M481</link>
      <description>The Measurement Studio .NET graphs do not use OLE Automation (the OA in From/ToOADate) dates for the conversion factor between DateTime and double.  OA date was natural for the ActiveX controls in Measurement Studio 6.0 since they are COM components, but there is not a precedent in .NET for what the double representation of a DateTime should be other than From/ToOADate, which are really convenience methods for interop with COM interfaces.&lt;BR /&gt;&lt;BR /&gt;The DateTime/double conversion factor that the Measurement Studio graphs use is a double value of 0.0 is equivalent to DateTime.MinValue and a double interval of 1.0 is equivalent to 1 second.  The NationalInstruments.DataConverter class will convert from/to double and DateTime and TimeSpan with this conversion factor.  F&lt;BR /&gt;or example, to convert a DateTime to a double as in your example above, you could do this:&lt;BR /&gt;&lt;BR /&gt;    DateTime rtime = Convert.ToDateTime(dRow["result_time"]);&lt;BR /&gt;    xData[i] = (double)DataConverter.Convert(rtTime, typeof(double));&lt;BR /&gt;&lt;BR /&gt;DataConverter will also convert arrays of DateTime to double, like this:&lt;BR /&gt;&lt;BR /&gt;    DataTime[] rtimes;&lt;BR /&gt;    // Initialize rtimes with an array of DateTime values.&lt;BR /&gt;    xData = (double[])DataConverter.Convert(rtimes, typeof(double[])); &lt;BR /&gt;&lt;BR /&gt;I will file a suggestion to improve the documentation regarding this conversion and its use with the graph in a future release.&lt;BR /&gt;&lt;BR /&gt;Also, you may want to look at using the WaveformGraph instead of the ScatterGraph.  The WaveformGraph and WaveformPlot plot methods have overloads for specifying DateTime and TimeSpan values for the start and increment.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;- Elton &lt;BR /&gt;</description>
      <pubDate>Tue, 04 May 2004 19:23:33 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/Measurement-Studio-for-NET/Axis-LabelFormat-doesn-t-convert-double-to-DateTime-correctly/m-p/131413#M481</guid>
      <dc:creator>Elton Wells</dc:creator>
      <dc:date>2004-05-04T19:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: Axis.LabelFormat doesn't convert double to DateTime correctly</title>
      <link>https://ni.lithium.com/t5/Measurement-Studio-for-NET/Axis-LabelFormat-doesn-t-convert-double-to-DateTime-correctly/m-p/131414#M482</link>
      <description>Great answer.  Super quick.  Thanks!!! &lt;BR /&gt;</description>
      <pubDate>Wed, 05 May 2004 00:29:15 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/Measurement-Studio-for-NET/Axis-LabelFormat-doesn-t-convert-double-to-DateTime-correctly/m-p/131414#M482</guid>
      <dc:creator>mturon</dc:creator>
      <dc:date>2004-05-05T00:29:15Z</dc:date>
    </item>
  </channel>
</rss>

