Skip to main content
HuntersGold
Inspiring
January 10, 2017
Question

Adding a dates to CpInfoCurrentDate

  • January 10, 2017
  • 1 reply
  • 606 views

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

    This topic has been closed for replies.

    1 reply

    Lilybiri
    Legend
    January 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

    HuntersGold
    Inspiring
    January 11, 2017

    Thanks for your quick response.

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

    TLCMediaDesign
    Inspiring
    January 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.