Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Adding a dates to CpInfoCurrentDate

Explorer ,
Jan 10, 2017 Jan 10, 2017

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

529
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 10, 2017 Jan 10, 2017

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:

Display Time information - Captivate blog

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 11, 2017 Jan 11, 2017

Thanks for your quick response.

I will look at using advanced actions and feedback on the amount of work required.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 11, 2017 Jan 11, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 11, 2017 Jan 11, 2017

David, I did suggest other vars than the time vars. Have done that

successfully, but agree that JS is more approoriate

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 11, 2017 Jan 11, 2017
LATEST
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources