Calculate Week Number or beginning/end of week - InfoPath Dev
in

InfoPath Dev

Calculate Week Number or beginning/end of week

Last post 11-08-2013 02:21 PM by KevinO. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 11-08-2013 08:52 AM

    Calculate Week Number or beginning/end of week

    Hi Everyone

    I've been developing infopath forms for a couple of years but a recent user of qrules.  I have a need to calculate either the week number or the beginning (Monday) and ending (Friday) dates of the week for a value selected in date picker.  I have seen posts that say this can be done with qrules but I'm not sure how.  Could someone provide me a little guidance?

    Thanks

    Kevin

  • 11-08-2013 09:21 AM In reply to

    Re: Calculate Week Number or beginning/end of week

     You bet. I don't think we have a way currently to return the week of the year based on a date (but that would be a good add - I'll put in a feature request). We have a command called "GetWeekDay" that I think you can use to easily get the Monday and Friday based on a date tho. Check the command overview for deets, but here is basic syntax:

     concat("GetWeekDay /date=", yourdatefield, " /day=Mo")

    Results will be returned to the results node in the data source, you can then copy that to another field. The /day param for Friday is "Fr".

    Hilary Stoupa

  • 11-08-2013 10:24 AM In reply to

    Re: Calculate Week Number or beginning/end of week

    Thanks for the quick reply Hilary.  I tried this but I can't seem to get anything working.  I created a button and assigned a rule to set the value of the command field and set it to this value concat("GetWeekDay /date=", DeliveryDate, "/day=Mo")  I also added the result, error and success fields to my form and those also have no change.  It seems like I have everything correct, any ideas?

    Kevin

  • 11-08-2013 10:28 AM In reply to

    Re: Calculate Week Number or beginning/end of week

     Sounds like qRules has been disabled - any chance you accidentally added custom code to your form? If you put the Command field on your form, type in GenerateGuid and tab out, what happens?

    Hilary Stoupa

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

    Re: Calculate Week Number or beginning/end of week

    You were correct.  I was using a version of the form where I had tried using a change event to get the week num.  However, on the older form with no code,  GetWeekDay is still not generating a result.  When I type GenerateGuid in the older form, I do get a result value but nothing with GetWeekDay

  • 11-08-2013 11:16 AM In reply to

    Re: Calculate Week Number or beginning/end of week

     Interesting! Can you attach a copy of your form under the Options tab? I'd like to take a look at it.

    Hilary Stoupa

  • 11-08-2013 11:22 AM In reply to

    Re: Calculate Week Number or beginning/end of week

    I should add - you do still have the error node where you can see it when you are trying this, right?

    Hilary Stoupa

  • 11-08-2013 11:44 AM In reply to

    Re: Calculate Week Number or beginning/end of week

    Yes, I do.  I've attached the form below.  I'm in the pharma industry so I had to remove the data connections, except qdabra, due to compliance requirements.  If you need to see those I'll have to work something out

  • 11-08-2013 11:49 AM In reply to

    Re: Calculate Week Number or beginning/end of week

     Thanks - I grabbed the template and then removed it from you post. I don't need the other data connections. :)

    Hilary Stoupa

  • 11-08-2013 12:06 PM In reply to

    Re: Calculate Week Number or beginning/end of week

     Okay, I just tested the command in your form - typed:

    GetWeekDay /date=2011-02-04 /day=Mo

    into the command field, tabbed out, and got:

    2011-01-31 in the result.

    Where are you trying to use the command?

    Hilary Stoupa

  • 11-08-2013 02:21 PM In reply to

    Re: Calculate Week Number or beginning/end of week

    Finally got it working.  I think I had a couple of spacing issues in the command line. Only been using qrules a couple of months but love it.

    Thanks for all the help

     

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