Highlighted

Auto calculate Dates?

Avatar

15-08-2008

Hello,

I'm in the process of designing a new time sheet for our employees. We have a box where the two week period the sheet is for needs to be entered, along with rows for each day, showing the amount of hours worked. Is there a way for our user to input the day the time sheet starts on and it automatically fill out the ending date and fill in each individual box.



If I confused anyone, just let me know and I'll clarify to the best of my ability.



Thanks in advance,

Justin

Replies

Highlighted

Avatar

Avatar

gkaiseril

Avatar

gkaiseril

gkaiseril

15-08-2008

You have to use the Date/Time object and the "Date2Num()" and "Num2Date()" functions. The format of of the date string is very necessary and important because if you do not have it correct for the date string being passed to the 'Date2Num()" funciton you will not get a valid answer.



The "Date2Num()" funciton will convert a passed date into the number of days from the fixed Epoch Date of LiveCycle Designer, you can then add the number of days for the next date you want and use the "Num2Date()" funciton to convert the new number of days from the Epoch Date to a date string.
Highlighted

Avatar

Avatar

jc2046

Avatar

jc2046

jc2046

04-01-2010

Here is the code I use.

Use this code on the a text field.

Put the following code as Calculate in FormCalc(exclude the ------- divider):

----------beginning of the code-----------

if

(HasValue(xyz)) then

Num2Date( (Date2Num(xyz.formattedValue

, "MM/DD/YYYY") + ###), "MM/DD/YYYY")

else

null

endif

--------ending of the code--------

=> Replace xyz with the field name, which your employee fills in

=> Replace ### with the number of days you want to add to