Calculate Week Number or beginning/end of week - InfoPath Dev Sign in | Join | Help in Qdabra qRules Qdabra Software Product Support (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » Qdabra Software Product Support » Qdabra qRules » Calculate Week Number or beginning/end of week 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: Oldest to newest Newest to oldest Previous Next 11-08-2013 08:52 AM KevinO Joined on 11-08-2013 Posts 12 Calculate Week Number or beginning/end of week Reply Contact 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 Filed under: infopath, week num, week number 11-08-2013 09:21 AM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Calculate Week Number or beginning/end of week Mark as Not AnswerMark as Answer... Reply Contact 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 KevinO Joined on 11-08-2013 Posts 12 Re: Calculate Week Number or beginning/end of week Mark as Not AnswerMark as Answer... Reply Contact 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 Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Calculate Week Number or beginning/end of week Mark as Not AnswerMark as Answer... Reply Contact 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 KevinO Joined on 11-08-2013 Posts 12 Re: Calculate Week Number or beginning/end of week Mark as Not AnswerMark as Answer... Reply Contact 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 Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Calculate Week Number or beginning/end of week Mark as Not AnswerMark as Answer... Reply Contact 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 Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Calculate Week Number or beginning/end of week Mark as Not AnswerMark as Answer... Reply Contact 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 KevinO Joined on 11-08-2013 Posts 12 Re: Calculate Week Number or beginning/end of week Mark as Not AnswerMark as Answer... Reply Contact 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 Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Calculate Week Number or beginning/end of week Mark as Not AnswerMark as Answer... Reply Contact 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 Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Calculate Week Number or beginning/end of week Mark as Not AnswerMark as Answer... Reply Contact Okay, I just tested the command in your form - typed:GetWeekDay /date=2011-02-04 /day=Mointo 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 KevinO Joined on 11-08-2013 Posts 12 Re: Calculate Week Number or beginning/end of week Mark as Not AnswerMark as Answer... Reply Contact 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.
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
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".
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?
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?
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
Interesting! Can you attach a copy of your form under the Options tab? I'd like to take a look at it.
I should add - you do still have the error node where you can see it when you are trying this, right?
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
Thanks - I grabbed the template and then removed it from you post. I don't need the other data connections. :)
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?
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