Calculating number of months in a date range - InfoPath Dev
in

InfoPath Dev

Calculating number of months in a date range

Last post 10-23-2015 02:18 PM by Hilary Stoupa. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 10-20-2015 02:21 PM

    Calculating number of months in a date range

    OK so I have to date picker fields. One is Start Date the Other is End Date. Is there any way I can pull the name (or number) of the months in that range? For example if I pick 2/15/2015 to 5/4/2015 I could get either February, March, April, May or 2,3,4,5,. I know using substring you can pull the number of the month for each date you pick and I know this can be done in Excel with a formula but can this be done in Infopath? Thanks so much for any answer I can get. Chris
  • 10-21-2015 07:45 AM In reply to

    Re: Calculating number of months in a date range

     I'm not sure what your desired outcome is, but here is a sample that displays the month range for two selected dates, leveraging an XML secondary data source. Save the attached file locally, right click to select design, then preview and select a start and end date for the range.

    Hilary Stoupa

  • 10-21-2015 10:24 AM In reply to

    Re: Calculating number of months in a date range

    Thank you so much for answering Hilary. Yes that is definitely what I would like to do. But can I use static fields instead of a repeating table? I am building this form on a list not a library. Basically my end goal is to have a section for each month. Hide those sections but have them appear dependent on the date range chosen. So I'd like to use the fields populated with the month names (very similar to your example form) to use a formatting rule to make the pertinent sections appear. That make sense?
  • 10-22-2015 02:18 PM In reply to

    Re: Calculating number of months in a date range

     Hmmm - so the sections will be in the main data source instead of a secondary data source? They won't be repeating, right - since this is a list form? So you'd have a column for each month and the user only fills out those that pertain?

    Hilary Stoupa

  • 10-22-2015 04:57 PM In reply to

    Re: Calculating number of months in a date range

    Exactly. Sections are in main data source the only thing is in each section I'll have a couple of text controls hence the need for a section to hide them all. But yes if I had a static column for each month and was able to fill each month column in the way you have it for your repeating section in your form I'd be able to hide or show a section. Hence if April is one of the months in the date range the April text box populates and then the April control with the various text boxes within it would appear. Again all in the main data source. So is this possible? Many many thanks for your help here.
  • 10-23-2015 11:11 AM In reply to

    Re: Calculating number of months in a date range

     Sure - the rules would be very similar to the ones on the repeating section. Basically, you need to get the month piece of the selected dates and then use conditional formatting to hide the sections that don't apply. Another simple sample attached.

    Hilary Stoupa

  • 10-23-2015 02:11 PM In reply to

    Re: Calculating number of months in a date range

    That worked! Hilary thank you so so much for you help. You are awesome. This is really useful info. Thanks again
  • 10-23-2015 02:18 PM In reply to

    Re: Calculating number of months in a date range

    Hooray! I'm glad you have it working the way you need it to! Great start to the weekend. :-)
    Hilary Stoupa

Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.