Add a number of months to a date - InfoPath Dev
in

InfoPath Dev

Add a number of months to a date

Last post 12-22-2015 03:49 PM by Hilary Stoupa. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 12-11-2015 04:06 AM

    Add a number of months to a date

     Hi,

    I was hoping somebody could help me!! please.

    I'm trying to create a running schedule, audit system within a InfoPath repeating table.  I'm using the perhaps not so clever function string "substring(datepicker1(), 6, 2)"  gives me a month number and using 12 rules, 1 = Jan, 2 = Feb..etc. seems to work fine.

    What I'm then trying to do is Add into a Datepicker2 field, Add a 2nd date, depending on a given period. (Not everyone does these audits every month) therefore, I have a standard textbox which I insert a value. 1 = monthly, or 5 = every 5 monthly. 5 being the maximum number I'll use as we have 5 people and therefor they'll do 1 audit every 5 months. 

     My idea was datepicker1 holds the month the person should complete the audit. datepicker2 holds the month that he will be next expected to audit. eg. picker1. [January], textbox = 5,  picker2. [June] - I then had a chkbox which when clicked, transfers the value of picker 2 to picker1 value and so on. 

     I was having some joy with this, that is until I reached December then adding a 1 value to 12 gives 13 and it all goes pear shape.

     I'm really looking for help how best to do this?

    Any help will be much appreciated.

    Thanks and Merry Christmas

    Mike 


  • 12-22-2015 03:49 PM In reply to

    Re: Add a number of months to a date

     Maybe add special handling if your result is > 12? If the result is > 12, you could subtract 12 from it and add to the year? Or just use the addDays function and multiply 30 by whatever the number of months is...?

    Hilary Stoupa

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