<?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>Newbie Questions</title><link>https://www.infopathdev.com:443/forums/39.aspx</link><description>New to InfoPath? Search to see if your question has already been answered. If it has not, then ask it here or the appropriate topic forum.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Field Required based on dates</title><link>https://www.infopathdev.com:443/forums/thread/4239.aspx</link><pubDate>Mon, 19 Mar 2007 16:43:56 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:4239</guid><dc:creator>Greg Collins</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/4239.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=4239</wfw:commentRss><description>Thanks so much Clay for the code!&lt;br /&gt;Art, let us know if this solves your issue.</description></item><item><title>Re: Field Required based on dates</title><link>https://www.infopathdev.com:443/forums/thread/4238.aspx</link><pubDate>Fri, 16 Mar 2007 20:58:50 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:4238</guid><dc:creator>Clay Fox</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/4238.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=4238</wfw:commentRss><description>Here are a couple of sample for VBScript.&lt;br /&gt;&lt;br /&gt;This one calculates a date 90 days in advance of today and stores it in a field in my form so I can use it to find data that is within 90 days. You could make the amount 10 instead.  If you go to tools and form options you can select whether you will use Java Script or VB Script.&lt;br /&gt;Then Tools -&amp;gt; programing -&amp;gt; On Load Event  then you could paste in the line starting with XDocument. You would need to modify the field description to match your particular schema.&lt;br /&gt;&lt;br /&gt;Sub XDocument_OnLoad(eventObj)&lt;br /&gt;XDocument.DOM.selectSingleNode("//dfs:myFields/my:Header/my:Variable").text = DateAdd("d",90,date)&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;This one is used to subtract 90 days from a date that has been entered by the user to set a start date for some workflow.&lt;br /&gt;&lt;br /&gt;This has been added to a button.&lt;br /&gt;&lt;br /&gt;Sub CTRL266_OnClick(eventObj)&lt;br /&gt;Dim job&lt;br /&gt;Dim action&lt;br /&gt;Dim SDate&lt;br /&gt;Dim nNode&lt;br /&gt;Dim flag&lt;br /&gt;Dim selectflag&lt;br /&gt;Dim formatDate&lt;br /&gt;Dim month&lt;br /&gt;Dim day&lt;br /&gt;Dim calcDate&lt;br /&gt;Dim newDate &lt;br /&gt;flag = "Manage"&lt;br /&gt;Set job = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:WFPJob")&lt;br /&gt;job.reset()&lt;br /&gt;Set nNode = job.nextNode()&lt;br /&gt;While Not(nNode Is Nothing)&lt;br /&gt;	selectflag = nNode.selectSingleNode("@SelectFlag").text&lt;br /&gt;	If flag = selectflag Then&lt;br /&gt;	SDate = nNode.selectSingleNode("@SDate").text&lt;br /&gt;	End IF&lt;br /&gt;	Set nNode = job.nextNode()&lt;br /&gt;WEnd&lt;br /&gt;&lt;br /&gt;Trim(SDate)&lt;br /&gt;formatDate = DateSerial(Mid(SDate, 1, 4), Mid(SDate, 6, 2), Mid(SDate, 9, 2))&lt;br /&gt;&lt;br /&gt;calcDate = DateAdd("d",-90,formatDate)&lt;br /&gt;month = DatePart("M", calcDate)&lt;br /&gt;If Len(month) = 1 Then&lt;br /&gt;	month= "0" &amp; month&lt;br /&gt;End If&lt;br /&gt;day = DatePart("D", calcDate)&lt;br /&gt;If Len(day) = 1 Then&lt;br /&gt;	day = "0" &amp; day&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;newDate = DatePart("YYYY", calcDate) &amp; "-" &amp; month &amp; "-" &amp; day&lt;br /&gt;&lt;br /&gt;Set action = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:WFPJob/d:WFPAction")&lt;br /&gt;action.reset()&lt;br /&gt;Set nNode = action.nextNode()&lt;br /&gt;While Not(nNode Is Nothing)&lt;br /&gt;	selectflag =nNode.selectSingleNode("@SelectFlag").text &lt;br /&gt;	If flag = selectflag Then&lt;br /&gt;	nNode.selectSingleNode("@ActionDate").text = newDate&lt;br /&gt;	End IF&lt;br /&gt;	Set nNode = action.nextNode()&lt;br /&gt;WEnd&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;I would do some research on DateAdd and DateDiff for VB if you need to do more.&lt;br /&gt;</description></item><item><title>Re: Field Required based on dates</title><link>https://www.infopathdev.com:443/forums/thread/4237.aspx</link><pubDate>Fri, 16 Mar 2007 16:33:29 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:4237</guid><dc:creator>Greg Collins</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/4237.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=4237</wfw:commentRss><description>With this requirement, you will of necessity have to be introduced to code (or move up to InfoPath 2007).&lt;br /&gt;&lt;br /&gt;There have been numerous discussions on how to write script for doing date math--both in these forums and across the internet. It shouldn't be to difficult to do a search to locate some code for that.&lt;br /&gt;&lt;br /&gt;If you have Visual Studio and are willing to do managed code (i.e. C# or VB.NET) then you will have built in date functions. Actually, I think VBScript also has date functions, whereas JScript does not.</description></item><item><title>Re: Field Required based on dates</title><link>https://www.infopathdev.com:443/forums/thread/4236.aspx</link><pubDate>Fri, 16 Mar 2007 12:56:55 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:4236</guid><dc:creator>oldradio99</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/4236.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=4236</wfw:commentRss><description>Since everything I have done so far in IP 2003 has been throiugh wizards, you both have lost me.&lt;br /&gt;&lt;br /&gt;I understand the concept of creating a non-displayed field to calculate the difference between two dates, but how do I write that "formula".&lt;br /&gt;&lt;br /&gt;I have never scripted or coded in IP 2003.&lt;br /&gt;&lt;br /&gt;Thanks&lt;br /&gt;</description></item><item><title>Re: Field Required based on dates</title><link>https://www.infopathdev.com:443/forums/thread/4235.aspx</link><pubDate>Thu, 15 Mar 2007 16:47:50 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:4235</guid><dc:creator>Greg Collins</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/4235.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=4235</wfw:commentRss><description>If you are using managed code instead of script, date functions are built-in so you don't need to write them.</description></item><item><title>Re: Field Required based on dates</title><link>https://www.infopathdev.com:443/forums/thread/4234.aspx</link><pubDate>Wed, 14 Mar 2007 22:15:03 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:4234</guid><dc:creator>Clay Fox</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/4234.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=4234</wfw:commentRss><description>Yah for 2003 you have to use the datediff function in code to calculate 10 days out. Store this in a field and then you cna do date comparisons against it  I can get you a sample if you need or there may be some already here if you search.</description></item><item><title>Re: Field Required based on dates</title><link>https://www.infopathdev.com:443/forums/thread/4233.aspx</link><pubDate>Wed, 14 Mar 2007 16:37:54 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:4233</guid><dc:creator>Greg Collins</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/4233.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=4233</wfw:commentRss><description>If you are using InfoPath 2007 there is built-in date math for such things. If you are using InfoPath 2003, you need to write code.</description></item><item><title>Field Required based on dates</title><link>https://www.infopathdev.com:443/forums/thread/1911.aspx</link><pubDate>Wed, 14 Mar 2007 13:07:27 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:1911</guid><dc:creator>oldradio99</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/1911.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=1911</wfw:commentRss><description>I think I know the answer but want to ask anyay  :)&lt;br /&gt;&lt;br /&gt;Using Infopath 2003.&lt;br /&gt;&lt;br /&gt;I have a field that I want to be required if a 'Needed by Date" is less than 10 days from today.&lt;br /&gt;&lt;br /&gt;Is there a way to compare today and the Date needed by to get the 10 day window without writing script?&lt;br /&gt;&lt;br /&gt;</description></item></channel></rss>