Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Need help with FormCalc calculating dates

Avatar

Level 2

I'm creating a timesheet and I'm trying to streamline it to make it easier to fill out. What I need FormCalc to do is calculate the pay period and auto-fill the Dates columns. So all the user will need to do is fill out the begining date of the pay period and then have rest be filled out automatically. Example:

Pay Period Beginning: 2011-06-05 (User Entered) Pay Period Ending: 2011-06-18 (Auto-Fill)

Week 1Date

In

OutInOutHours Worked
Sunday05 (Auto-Fill)
Monday06 (Auto-Fill)
Tuesday07 (Auto-Fill)
Wednesday08 (Auto-Fill)
Thursday09 (Auto-Fill)
Friday10 (Auto-Fill)
Saturday11 (Auto-Fill)

Week 2DateInOutInOutHours Worked
Sunday12 (Auto-Fill)
Monday13 (Auto-Fill)
Tuesday14 (Auto-Fill)
Wednesday15 (Auto-Fill)
Thursday16 (Auto-Fill)
Friday17 (Auto-Fill)
Saturday18 (Auto-Fill)

I don't even know where to begin with accomplishing this. So any help is greatly appreciated.

2 Replies

Avatar

Level 6

It is simple all you need to do is use Date2Num and Num2Date inbuilt functions.... Here is what I have tried....

I used a table with 7rows and in the 2nd column I used Date/Time Field in each one of those. I named one after another as week1sunday, week1monday....

then except the fist one (week1sunday) rest of the ones I made readOnly. Now in the change event of week1sunday I used the following code to produce the calculating effect....this is FormCalc code

$.parent.parent.Row2.week1monday.rawValue = Num2Date(Date2Num(xfa.event.change,"M/D/YY")+1,"M/D/YY")

$.parent.parent.Row3.week1tuesday.rawValue = Num2Date(Date2Num(xfa.event.change,"M/D/YY")+2,"M/D/YY")

Of course you need to match with your SOM hierarchy but you can use the concepts.

Good luck,

Avatar

Level 2

Thank you very much for your answer. But I am also very new to this and was wondering if you could go into more detail. I'm not sure how this will accomplish what I need. What I need is for the Pay Period Begining (Named PPBegin) date to be entered manualy. Then the Pay Period End date to be automatically filled out by adding 14 days to the PPBegin date. Then in the tables I need each cell in the Date column to automatically fill out based on the PPBegin date. What I tried doing before coming here was just putting PPBegin in the Wk1Sun cell and then in the cells below that I put 1+Wk1Sun, 1+Wk1Mon, etc. This would kind of give me what I want except for when I got to the end of the month. So could you break down in detail what this means:

$.parent.parent.Row2.week1monday.rawValue = Num2Date(Date2Num(xfa.event.change,"M/D/YY")+1,"M/D/YY")

I know it may be simple for you but it looks completly greek to me.