I am trying to calculate dates for a two-week timesheet. The person doing the timesheet enters the pay period ending date. When they click on to the next box, where they enter their name, etc., I want to automatically fill in the dates next to each day in the table for the next 14 days. I decided to subtract one from the pay period ending date, insert that in the area next to Friday (6th day, 2nd week), and so on until I got to the first day in the pay period, which would equal the (pay period ending date - 13). Pretty simple to explain, but I have no idea how the code should look, and if I calculate, or click, or what.
I have seen the Num2Date and Date2Num functions, but I don't know where I should be doing these calcs and how to define the field that is the answer so I can then display this in the table. I have tried to create calculations that reference a field I have defined as read only for each date. Except I get errors that say Wk2Fri is no good. Do I have to define that field somewhere in the code, and if I do, where and how?
Is there a book that explains some of this stuff out there. I get tired of asking and looking like an idiot.
If anyone wants to see the form, leave an email address and I'll send it to you. The attach files routine is not working (at least it wasn't the last time I tried it.) I'll try to aattach it now. Let me know if you can't see it.
Thanks for your help.
Solved! Go to Solution.
Views
Replies
Total Likes
Here is my cut at your form. It is not quite complete. It takes the date from the date picker and uses the FormCalc date2num and num2date functions to populate the table with the dates for the two week period preceeding the end date.
The attached .png highlights the result of picking an end date that is not a Saturday.
Steve
Views
Replies
Total Likes
There is no such thing as a bad question.
Forward the form to stwalker.adobe@gmail.com and I will take a look.
Steve
Views
Replies
Total Likes
Here is my cut at your form. It is not quite complete. It takes the date from the date picker and uses the FormCalc date2num and num2date functions to populate the table with the dates for the two week period preceeding the end date.
The attached .png highlights the result of picking an end date that is not a Saturday.
Steve
Views
Replies
Total Likes
Thanks for the help, Steve.
Views
Replies
Total Likes
Steve -
Not sure what is happening, but sometimes when I test the form, the date gets filled in after entering the first date, and sometimes it doesn't. I can tell you that after entering the two weeks ending date, the date field in the first column gets filled in with that date, but the other dates and the days do not automatically populate. I thought I had a problem, but then it started working. Not it isn;t. I tried it in both Designer, Acrobat Pro and Acrobat. When ti works, it works in all three. When it doesn't, it doesn't in all three. ANy good ideas?
Thanks for your help. I appreciate it very much.
DF
BTW I have attached my latest version.
Views
Replies
Total Likes
Looks like when I enter a two week end date that includes today's date, it doesn't work. If I move it our a week use that as an end date, the dates populate. Try it. Use May 9 as the end date and see what happens. The use May 16. It works. Go figure. Any ideas? Thanks.
Views
Replies
Total Likes
Wow. That is weird. I will look into it.
Views
Replies
Total Likes
Hi,
I think that the.... ".formattedValue,"MMMM DD, YYYY")" in the script should only have one "D" to match the date pattern in the cell/object pattern tab.
Hope this helps,
N.
Niall is absolutely correct. I made the mistake of incorrectly formatting the two week ending date in the calculation for the previous 14 days.
I had
var dateNum = date2num(form1.page1.header.twoWeeksEnding.formattedValue,"MMMM DD, YYYY")
$ = num2date(dateNum,"MM/DD")
It should be
var dateNum = date2num(form1.page1.header.twoWeeksEnding.formattedValue,"MMMM D, YYYY")
$ = num2date(dateNum,"MM/DD")
The corrected version is attached.
Steve
Views
Replies
Total Likes
Thanks, Niall, and thanks, Steve. I appreciate all the help on this.
Views
Replies
Total Likes