<?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>General</title><link>https://www.infopathdev.com:443/forums/41.aspx</link><description>If you're not sure where to ask your question, ask it here. If necessary, our moderators will make sure it gets classified in the correct board.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Date in a date picker from a date object</title><link>https://www.infopathdev.com:443/forums/thread/46233.aspx</link><pubDate>Wed, 26 Aug 2009 02:14:53 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:46233</guid><dc:creator>tfiema</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/46233.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=46233</wfw:commentRss><description>&lt;p&gt;to set date picker value from code you need to set its nil attribute to false. To do that use the toggle code below. but toggling it back to ture is a bit tricky. I usually set the value of the datepicker to &amp;quot;&amp;quot; from a rule and then use the toggle code to set the nil attrib to true (rules fire first code comes after). I wouldn&amp;#39;t delete the attribute, you might need to recreate it later and that&amp;#39;s just more work.&lt;/p&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;private&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;void&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; ToggleXsiNilInMain(&lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; xpath, &lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; attValue)&lt;/font&gt;&lt;font size="1"&gt;{&lt;/font&gt;&lt;font size="1"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#008080" size="1"&gt;&lt;font color="#008080" size="1"&gt;XPathNavigator&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; mainNode = MainDataSource.CreateNavigator().SelectSingleNode(xpath + &lt;/font&gt;&lt;font color="#800000" size="1"&gt;&lt;font color="#800000" size="1"&gt;&amp;quot;/@xsi:nil&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt;, NamespaceManager);&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;if&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; (mainNode != &lt;/font&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#0000ff" size="1"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt;){mainNode.SetValue(attValue);}&lt;/font&gt;&lt;/font&gt;&lt;font size="1"&gt; 
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Re: Date in a date picker from a date object</title><link>https://www.infopathdev.com:443/forums/thread/40408.aspx</link><pubDate>Tue, 07 Apr 2009 23:35:57 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:40408</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/40408.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=40408</wfw:commentRss><description>&lt;p&gt;Thank you for your contribution, esorio!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/infopathdev/images/icon-quote.gif"&gt; &lt;strong&gt;eosorio:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;// Build the current date in the proper format. (yyyy-mm-dd)&lt;br /&gt;string curDate = DateTime.Today.Year + &amp;quot;-&amp;quot; + DateTime.Today.Month +&amp;nbsp;&amp;quot;-&amp;quot; + DateTime.Today.Day;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;
&lt;p&gt;This will not actually put the date in the correct format if &lt;em&gt;Month&lt;/em&gt; or &lt;em&gt;Day&lt;/em&gt; is a single digit on the day when the code is run.&amp;nbsp; I recommend using the following:&lt;/p&gt;&lt;font size="2"&gt;&lt;/font&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; curDate = &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;DateTime&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.Today.ToString(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;yyyy-MM-dd&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/p&gt;&lt;/blockquote&gt;&lt;/font&gt;</description></item><item><title>Re: Date in a date picker from a date object</title><link>https://www.infopathdev.com:443/forums/thread/40402.aspx</link><pubDate>Tue, 07 Apr 2009 20:15:20 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:40402</guid><dc:creator>eosorio</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/40402.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=40402</wfw:commentRss><description>&lt;p&gt;Great info Greg!!, thanks&lt;br /&gt;&lt;/p&gt;&lt;p&gt;just pointing to msdn info where &amp;quot;how to&amp;quot; copy code&lt;/p&gt;&lt;p&gt;http://msdn.microsoft.com/en-us/library/bb509311.aspx&lt;/p&gt;&lt;p&gt;&amp;nbsp;public void DeleteNil(XPathNavigator node)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; if (node.MoveToAttribute(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot;nil&amp;quot;, &amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; node.DeleteSelf();&lt;br /&gt;}&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;// Access the main data source.&lt;br /&gt;XPathNavigator myForm = MainDataSource.CreateNavigator();&lt;br /&gt;&lt;br /&gt;// Select the field.&lt;br /&gt;XPathNavigator myDate = myForm.SelectSingleNode(&amp;quot;/my:myFields/my:myDate&amp;quot;, NamespaceManager);&lt;br /&gt;&lt;br /&gt;// Check for and remove the &amp;quot;nil&amp;quot; attribute.&lt;br /&gt;DeleteNil(myDate);&lt;br /&gt;&lt;br /&gt;// Build the current date in the proper format. (yyyy-mm-dd)&lt;br /&gt;string curDate = DateTime.Today.Year + &amp;quot;-&amp;quot; + DateTime.Today.Month + &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;quot;-&amp;quot; + DateTime.Today.Day;&lt;br /&gt;&lt;br /&gt;// Set the value of the myDate field.&lt;br /&gt;myDate.SetValue(strCurDate); &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Date in a date picker from a date object</title><link>https://www.infopathdev.com:443/forums/thread/28044.aspx</link><pubDate>Thu, 17 Apr 2008 17:37:09 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:28044</guid><dc:creator>Greg Collins</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/28044.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=28044</wfw:commentRss><description>&lt;p&gt;I should mention that the string data type can be blank whenever it wants and does not use the xsi:nil attribute. Formatting is not important on a string type either.&lt;/p&gt;</description></item><item><title>Re: Date in a date picker from a date object</title><link>https://www.infopathdev.com:443/forums/thread/28043.aspx</link><pubDate>Thu, 17 Apr 2008 17:36:18 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:28043</guid><dc:creator>Greg Collins</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/28043.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=28043</wfw:commentRss><description>&lt;p&gt;XML, and thus InfoPath, expect a date to be formatted like: 2008-04-17 (yyyy-MM-dd), and a datetime to be formatted as 2008-04-17T11:34:23 (yyyy-MM-ddThh:mm:ss).&lt;/p&gt;
&lt;p&gt;You must also, when populating a date node via code, ensure that the xsi:nil attribute is removed before trying to set the value, or you will receive an error. The use of xsi:nil=&amp;quot;true&amp;quot; means that you won&amp;#39;t see a red asterisk on the date picker field.... but it also means that it is expecting the field value to be blank. So you must remove the attribute BEFORE setting the value. When clearing the value, you will likely want ot add the attribute back onto the node.&lt;/p&gt;</description></item><item><title>Date in a date picker from a date object</title><link>https://www.infopathdev.com:443/forums/thread/28022.aspx</link><pubDate>Thu, 17 Apr 2008 12:42:44 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:28022</guid><dc:creator>shayrlz</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/28022.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=28022</wfw:commentRss><description>&lt;p&gt;Can I put a date in a date picker from a date object using code?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tried using many different ways but always but always the date returned is in a format different of the expected by the date picker.&lt;/p&gt;
&lt;p&gt;I only have sucess using string, but I want to try using a date object.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Anyone know how to format the date object to tranfer the values to a date picker?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;After that I ll use two date values to make a calendar exibition.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;</description></item></channel></rss>