Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Java code for current date plus 30 days

Anonymous
Not applicable

I've searched this forum and google to see if I could get something to work with negative results. I created a form on Livecycle 8.2 and I'm trying to set a due date 30 days from todays date. When the form is opened I have the current date and time, read only, displayed so I would also like the due date to automatically show. I know nothing about Java and what I've used so far I've been able to copy and paste to my form. Any help would be greatly appreciated.

1 Accepted Solution
whyisthisme
Correct answer by
Level 7
Level 7

It has been over-complicated. All you need is:

$ = Num2Date(date() + 30, "MM/DD/YYYY")

View solution in original post

10 Replies
whyisthisme
Level 7
Level 7

You use the Date2Num and Num2Date functions to do this. You turn the first date into a number using Date2Num then add 30 to it and turn it back into a date using Num2Date.

Anonymous
Not applicable

Hmmm. I've seen these in my searching but have no idea what to do with them. Thanks.

Vjay_Reddy
Level 5
Level 5

Drag date field  and select layout ready event and language - formcalc and keep below script that would help you.

$.rawValue= num2date(date2num(num2date(date(), DateFmt(3)))+30)

Vjay

Anonymous
Not applicable

Thanks. It worked but what would I do to display the date as MM/DD/YYYY and make it read only?

Anonymous
Not applicable

I have the read only part worked out and have been playing with the format but can't get it to display how I want it.

Vjay_Reddy
Level 5
Level 5

$.rawValue= num2date(date2num(num2date(date(), "MM/DD/YYYY"))+30)

Check this it might work.

Vjay

Anonymous
Not applicable

I actually tried this earlier this morning and it returns the date "Jan 30, 1900".

whyisthisme
Correct answer by
Level 7
Level 7

It has been over-complicated. All you need is:

$ = Num2Date(date() + 30, "MM/DD/YYYY")

Anonymous
Not applicable

Exactly what I needed and it works perfectly! Thank you soooo much!

Akyron
Level 2
Level 2

I need this but in Java not FormCalc. Using the tools actionbuilder converts everything to java and nullifies FormCalc....blah