Copy link to clipboard
Copied
Hi All,
Is it possible to have a variable that would add dates to the current date variable?
I have a text caption that generates the current date and a textbox entry where I would expect users to enter a number of days. That number of days would need to be added on to the 'CpInfoCurrentDateStringDDMMYYYY' and output a date result in a separate text caption.
Second question: Is it possible to trim the seconds from 'cpInfoCurrentTime' so that it can just show HH:MM.
I am using CP9.
Many thanks
Copy link to clipboard
Copied
The date is not a 'function' like in other applications (Excel to name one).
Why not use another system variable to calculate the 'day': cpInfoCurrentDate gives you the day number. Today in Belgium is '10'.
You will have to construct the date to be shown, by adding cpInfoCurrentMonth and cpInfoCurrentYear. Since the date can be >31, you'll need some more actions to be sure you end up with an existing complete date.
This would probably be much easier using a small JS script. Same for trimming the seconds.
This article is bit related, but could be interesting to see how much work is involved if you use advanced actions:
Copy link to clipboard
Copied
Thanks for your quick response.
I will look at using advanced actions and feedback on the amount of work required.
Copy link to clipboard
Copied
To add or subtract dates, you will need to get the actual milliseconds for both, add or subtract and then get a new Date from the milliseconds.
You will definitely need to use JavaScript as in some months or days, an advanced action will not return the expected result.
Copy link to clipboard
Copied
David, I did suggest other vars than the time vars. Have done that
successfully, but agree that JS is more approoriate
Copy link to clipboard
Copied
You might find this post useful:
http://www.infosemantics.com.au/adobe-captivate/template/02-dynamic-date-functions