<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Set value as datetime?</title><link>https://www.infopathdev.com:443/forums/thread/38525.aspx</link><pubDate>Tue, 17 Feb 2009 19:52:49 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:38525</guid><dc:creator>geoffc</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/38525.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=38525</wfw:commentRss><description>nevermind, I figured this out. instead of ToShortDateString(), I used ToString(&amp;quot;yyyy-MM-dd&amp;quot;)</description></item><item><title>Set value as datetime?</title><link>https://www.infopathdev.com:443/forums/thread/38513.aspx</link><pubDate>Tue, 17 Feb 2009 16:28:05 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:38513</guid><dc:creator>geoffc</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/38513.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=38513</wfw:commentRss><description>&lt;font size="2"&gt;
&lt;p&gt;I am doing some date calculations through code and am trying to set a couple nodes on my infopath form to these returned values. I would like to set them as datetime but I am not sure how to do that. I am currently setting them as strings. However, this is a problem because I get data validation errors since the nodes&amp;nbsp;use the&amp;nbsp;datetime data type. Is there a way to set them as datetime rather than converting them to strings? This is probably easier to understand by looking at my code:&lt;/font&gt;&lt;/p&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt; scd2 = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt;.Empty;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt; scd3 = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt;.Empty;&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt; scd = MainDataSource.CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/dfs:myFields/my:queryResults2/my:resultsRow2/my:scd&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager).Value;&lt;/font&gt;&lt;/p&gt;&lt;font color="#008080" size="2"&gt;D&lt;/font&gt;&lt;font color="#008080" size="2"&gt;ateTime&lt;/font&gt;&lt;font size="2"&gt; dt = &lt;/font&gt;&lt;font color="#008080" size="2"&gt;Convert&lt;/font&gt;&lt;font size="2"&gt;.ToDateTime(scd).AddMonths(18);&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;scd2 = dt.ToShortDateString();&lt;/p&gt;
&lt;p&gt;e.Source.SelectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/dfs:myFields/my:scd2&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager).SetValue(scd2);&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;DateTime&lt;/font&gt;&lt;font size="2"&gt; dt2 = &lt;/font&gt;&lt;font color="#008080" size="2"&gt;Convert&lt;/font&gt;&lt;font size="2"&gt;.ToDateTime(dt).AddMonths(18);&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;scd3 = dt2.ToShortDateString();&lt;/p&gt;
&lt;p&gt;e.Source.SelectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/dfs:myFields/my:scd3&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager).SetValue(scd3);&lt;/p&gt;&lt;/font&gt;</description></item></channel></rss>