Get number of months in Decimals between two Date Pickers then round up. - InfoPath Dev
in

InfoPath Dev

Get number of months in Decimals between two Date Pickers then round up.

Last post 06-27-2011 01:15 PM by Juan Sanchez. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 06-27-2011 05:33 AM

    Get number of months in Decimals between two Date Pickers then round up.

    With the awsome blogs in this forum, I was able to get the number of months between 2 date pickers as described below:

    12 * (substring(PERIOD THRU DATE, 1, 4) - substring(PERIOD FROM, 1,4)) + (substring(PERIOD THRU DATE, 6, 2) - substring(PERIOD FROM, 6, 2))

    But the results I need are months in decimals and then round up if greater than (.5), for example:

    If I have 75 days I need it to be divided by 30 days and then display the results in decimal months which would be (2.5 months) and if greater than (.5 ) then it needs to round up to 3 months. I hope there are formulas that can be combined to get the desired results, without code. Is there anyone that has the knowledge to accomplish this capability?

    Thanks in advance!

    Juan

    Filed under:
  • 06-27-2011 06:02 AM In reply to

    Re: Get number of months in Decimals between two Date Pickers then round up.

    You can use the codeless date diff trick or qRules (which is somewhat simpler) to get the number of days between two dates:

    http://alecpojidaev.wordpress.com/2008/12/30/infopath-codeless-programming-walkthrough-2/

    Then you can take the result, divide it by 30, and use the round() function to round it.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 06-27-2011 01:15 PM In reply to

    Re: Get number of months in Decimals between two Date Pickers then round up.

    Thank you very much, Jimmy!

     Juan

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