Adding dates in infopath 2003 - InfoPath Dev
in

InfoPath Dev

Adding dates in infopath 2003

Last post 10-07-2010 07:59 PM by Jimmy. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 09-30-2010 02:19 PM

    Adding dates in infopath 2003

    I have a check out date and return date on my form.  When the user selects the check out date, the form validates that the checkout date entered is no more than 7 days from the current  date.  Got that piece working fine.  When the user selects the return date, I am trying to make the form validate that the return date is no more than 7 days from the selected check out date.  Here is what I thought would work:

     function msoxd_my_returnDate::OnValidate(eventObj)

    {

         var formOutDate = XDocument.DOM.selectSingleNode("//my:outDate");

         var formReturnDate = XDocument.DOM.selectSingleNode("//my:returnDate");

             if (eventObj.Site.nodeTypedValue != "")

             {

                   var myDate = new Date(formOutDate.text);

                   myDate.setDate(myDate.getDate()+7);

                   if (myDate < formReturnDate.text)

                        {

                                XDocument.UI.Alert("Return date can not be more than 7 days from the checkout date.");

                         }

             }

    }

     

  • 10-05-2010 11:57 PM In reply to

    Re: Adding dates in infopath 2003

    You can do this without code. Take a look at the Meeting Agenda (Detailed) form template available for free from Microsoft's web site (Google: InfoPath form template Meeting Agenda). There should be a 2003 form available. This form also shipped as one of the 2003 out-of-box solutions - I know because my team built those for the launch of 2003. Anyway, Meeting Agenda has a special rule that checks preceding-sibling and verified that the agenda items don't occur at overlapping times. You can use the same kind of logic to ensure a 7 day span. Using an xpath to add days to your field and compare the dates against that is relatively easy to do. No coding required. 

     

    Patrick Halstead
    Project Manager at Qdabra
  • 10-07-2010 09:26 AM In reply to

    Re: Adding dates in infopath 2003

    Thanks Patrick,

     I took a look at the 2003 Meeting Agenda template and it looks like it uses comparison of dates, if date 1 < date 2.  But I need to add 7 days to my date 1 and then compare the new date value to date 2. 

  • 10-07-2010 09:31 AM In reply to

    Re: Adding dates in infopath 2003

    Please disregard my earlier post if you've already read it. I didn't notice you're using IP 2003.

     To the best of my recollection, the JScript Date() constructor does not accept dates in ISO (yyyy-mm-dd) format.  You need to parse out the individual parts and call the Date constructor that takes three arguments:

    Date(year, month, day)

    Once you have your date object and have added 7 days to it, you need to call getYear(), getMonth(), and getDay() to put the date back together as an ISO date string before you try to compare it to your other date value.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 10-07-2010 12:07 PM In reply to

    Re: Adding dates in infopath 2003

    Jimmy,

    I guess my question is how do I take that date value entered in the form and "parse out the individual parts"?

  • 10-07-2010 07:59 PM In reply to

    Re: Adding dates in infopath 2003

    http://www.google.co.jp/search?q=javascript+substring&rls=com.microsoft:en-us&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1&redir_esc=&ei=yoiuTNi6DY_0swO-g_GXDA

     InfoPath's dates are always in the format yyyy-mm-dd, so extracting out the three parts should be pretty straightforward.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.