<?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: Setting a date from Code causes validation error</title><link>https://www.infopathdev.com:443/forums/thread/61747.aspx</link><pubDate>Mon, 29 Nov 2010 16:45:13 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:61747</guid><dc:creator>denfer06</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/61747.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=61747</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Hello,&lt;/p&gt;&lt;p&gt; for people that want a sample the below format solved be above issue on my side:&lt;/p&gt;&lt;p&gt;ideaNav.SelectSingleNode(&amp;quot;@my:InitalReviewDeliveryDate&amp;quot;, NamespaceManager).SetValue(currentDate.ToString(&amp;quot;yyyy-MM-ddTHH:mm:ss&amp;quot;));&lt;/p&gt;&lt;p&gt;this is the default date&amp;amp;time format used by InfoPath that you can find in saved XML.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;thanks for your help&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Setting a date from Code causes validation error</title><link>https://www.infopathdev.com:443/forums/thread/44705.aspx</link><pubDate>Tue, 21 Jul 2009 06:50:57 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:44705</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/44705.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=44705</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;FormatDateTime(&lt;b&gt;DATE&lt;/b&gt;, 2) will format the date with slashes in the order month, date, year (e.g. 7/21/2009), but an XML date must be of the form YYYY-MM-DD, i.e., year, month, date separated by hyphens and with padding zeros where necessary. FormatDateTime does not seem to have the option to format a date this way, so it may make sense to write your own convenience function to get the proper format.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Setting a date from Code causes validation error</title><link>https://www.infopathdev.com:443/forums/thread/44704.aspx</link><pubDate>Tue, 21 Jul 2009 06:11:46 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:44704</guid><dc:creator>djj66</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/44704.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=44704</wfw:commentRss><description>&lt;p&gt;Hi there, thanks, but this doesn&amp;#39;t appear to make any difference...&lt;/p&gt;
&lt;p&gt;I can set the control as DateTime and from code set the control either as date only or date and time, and it always gets the validation error.&lt;/p&gt;
&lt;p&gt;Then as soon as I make even the smallest edit the the value, the validation problem disappears.&lt;/p&gt;
&lt;p&gt;From what I see, the code is working perfectly, but the form control initially rejects the set value with the validation. I&amp;#39;ve tried most things with the form control, and haven&amp;#39;t been able to fix yet. Any other suggestions?&lt;/p&gt;</description></item><item><title>Re: Setting a date from Code causes validation error</title><link>https://www.infopathdev.com:443/forums/thread/44696.aspx</link><pubDate>Tue, 21 Jul 2009 05:15:59 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:44696</guid><dc:creator>Patrick Halstead</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/44696.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=44696</wfw:commentRss><description>&lt;p&gt;Hi Djj66,&lt;/p&gt;
&lt;p&gt;Not sure, but you are using FormatDateTime and you said the element was a Date not a DateTime. If you change it to DateTime does that change your mileage?&lt;/p&gt;
&lt;p&gt;Just wondering...&lt;/p&gt;</description></item><item><title>Setting a date from Code causes validation error</title><link>https://www.infopathdev.com:443/forums/thread/44694.aspx</link><pubDate>Tue, 21 Jul 2009 01:04:07 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:44694</guid><dc:creator>djj66</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/44694.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=44694</wfw:commentRss><description>&lt;p&gt;Hi all, I have got a piece of code which sets the date on a control on my InfoPath form (VBScript and IP 2003). The code I have is...&lt;/p&gt;
&lt;p&gt;Dim dtTargetComplete &lt;/p&gt;
&lt;p&gt;dtTargetComplete = XDocument.DOM.selectSingleNode (&amp;quot;/dfs:myFields/my:TargetCompleteDate&amp;quot;).text dtTargetComplete = DateAdd(&amp;quot;d&amp;quot;,7,now) &lt;/p&gt;
&lt;p&gt;if XDocument.DOM.selectSingleNode (&amp;quot;/dfs:myFields/my:TargetCompleteDate&amp;quot;).removeAttribute(&amp;quot;xsi:nil&amp;quot;) then &lt;/p&gt;
&lt;p&gt;XDocument.DOM.selectSingleNode (&amp;quot;/dfs:myFields/my:TargetCompleteDate&amp;quot;).text = FormatDateTime(dtTargetComplete,2) &lt;/p&gt;
&lt;p&gt;else XDocument.DOM.selectSingleNode (&amp;quot;/dfs:myFields/my:TargetCompleteDate&amp;quot;).text = FormatDateTime(dtTargetComplete,2) &lt;/p&gt;
&lt;p&gt;end if&lt;/p&gt;
&lt;p&gt;Now this code works OK, and correctly sets the date in the contol. But when the date is set in the control, the control appears with dotted red border, as with a validation error. If I then make a slight edit to the data&amp;nbsp;in the contol (eg replace 2009 with 2009) then the validation error disappears. The control is defined as a Date, not a text or number.&lt;/p&gt;
&lt;p&gt;Does anyone know how to avoid this validation error when setting dates from Code. Many thanks!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>