DatePicker - default to previous month? - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

DatePicker - default to previous month?

Last post 10-25-2012 09:10 AM by APMOB. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 10-25-2012 03:12 AM

    • APMOB
    • Not Ranked
    • Joined on 09-06-2012
    • Posts 6

    DatePicker - default to previous month?

    Hi all,

    Does anybody know if/how it is possible to set a datepicker control value to default to the previous month?

    So, for example, if someone were to open the form today (Oct 25th), the datepicker would default to Sep 25th?

    (The exact date isn't important - I'm really only concerned with the month - so any date in September would be fine...)

    I'm sure it involves a combination of the addDays and today functions but not sure how to formulate them?

    Any suggestions would be most welcome!

    Thanks

    APMOB

  • 10-25-2012 09:10 AM In reply to

    • APMOB
    • Not Ranked
    • Joined on 09-06-2012
    • Posts 6

    Re: DatePicker - default to previous month?

    Figured it out...

    I used this formula to define the default value of the date picker control :

    addDays(today(), -((number(substring(today(), 9, 2)) + 1)))

    This takes today's date (Oct 25th) , and deducts the number of days passed in the current month (25), plus one extra (i.e. 26)

    Thus returning the last day of the previous month (i.e. Sep 30th)

    With the date picker formatted to mmmm yyyy, this shows as the previous month (September 2012)

    (Although be aware / warned, the full value is technically the last day of the previous month, i.e, Sep 30th...)

    APMOB

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