Default Date to First Day of Next Month - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Default Date to First Day of Next Month

Last post 04-06-2020 08:53 AM by Hilary Stoupa. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 11-04-2013 09:18 AM

    Default Date to First Day of Next Month

    I'm trying to write a formula that will set the default date on a date picker control to the first day of the next month. For example, if I were filling out the form today (November 4th), the default value of the date picker would be the 1st of December. Or if I was filling out the form on the 20th of July, the default would be the 1st of August. Any answers or direction are greatly appreciated.
  • 11-04-2013 12:07 PM In reply to

    Re: Default Date to First Day of Next Month

     This would get a little tricky with default values, but can be done rather simply using rules. I've attached a sample - save it locally, right click and select design to open in design mode. The only problem you may have is that the rules could execute again and overwrite the user's entry, so you may need to add some other logic to handle for that.

    Hilary Stoupa

  • 11-05-2013 05:57 AM In reply to

    Re: Default Date to First Day of Next Month

    Thank you so much!
  • 11-06-2013 12:41 PM In reply to

    Re: Default Date to First Day of Next Month

    This is the form we were talking about in our messages :)
  • 11-06-2013 12:46 PM In reply to

    Re: Default Date to First Day of Next Month

     Where is your rule? I expected to see it on the Order Date - is it someplace else?

    Hilary Stoupa

  • 11-06-2013 02:05 PM In reply to

    Re: Default Date to First Day of Next Month

    I used the created field to populate the "First Day of the Month" field. And the order Date field is defaulted to the "first day of the month" field. I needed to make sure that the Date field can be changed later on.
  • 11-06-2013 03:28 PM In reply to

    Re: Default Date to First Day of Next Month

     Can you attach a screenshot under the options tab showing the issue?

    Hilary Stoupa

  • 11-07-2013 08:40 AM In reply to

    Re: Default Date to First Day of Next Month

    Here is my problem. I'm using another date field to populate the Order Date field. The functionality is great and working fine, it's the formatting however that I can't figure out. I need the date to display as month/day/year format rather than year-month-day format. The form that you sent me is in the right format, but because I am using a SharePoint list and not a Form Library the date that is being pushed out is in the wrong format. Without the right format the user would have to retype in the correct format or use the calendar icon to pick a different date.
  • 11-07-2013 08:50 AM In reply to

    Re: Default Date to First Day of Next Month

    Ah, now I know what's up. We need to add " 00:00:00" to the date. That's a space and 0s for time for hours, minutes, etc. This is because SharePoint doesn't have a date data type, but has a date time data type. Can you try that? With a concat? And see if that helps?

    Hilary Stoupa

  • 04-06-2020 06:56 AM In reply to

    Re: Default Date to First Day of Next Month

    I know this is many years after the fact but I figured out a solution to this and figured I would post it in case someone else came across this thread... Adding T00:00:00 to the end of the string doesn't solve it because what's happening is that when the formula adds one "+ 1" to the month string, it turns it into a single digit if your month is one of the first 9 months of the year. You need to create a field that will force a value with 2 digits and then incorporate that into your formula. So I ended up with three separate fields - possibly overkill but it works so here how it is set up:

    1. Month_After_Received
    Text field; its value is set by Date_Received.

    2. Month_After_Recd_TwoDigits
    Text field, its default value is:
    concat(substring('00', 1, 2 - string-length(Month_After_Received)), Month_After_Received)

    3. Date_Received:

    // extract the month from this field and add 1 to it
    a. Condition: When field changes
    Action: Month_After_Received to: number(substring(., 6, 2)) + 1

    // this is for all months other than December
    b. Condition: substring(., 6, 2) != 12
    Action: Date_Due = concat(substring(., 1, 4), "-", Month_After_Recd_TwoDigits, "-01T00:00:00")

    // this is for December
    c. Condition: substring(., 6, 2) = 12
    Action: Date_Due = concat(substring(., 1, 4) + 1, "-01-01T00:00:00")
  • 04-06-2020 08:53 AM In reply to

    Re: Default Date to First Day of Next Month

    Thanks so much for taking the time to share your solution! :)
    Hilary Stoupa

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