Skip to main content
gcayton78
Known Participant
February 8, 2022
Answered

Date Format Captivate Variables

  • February 8, 2022
  • 1 reply
  • 1145 views

First time posting, and I could not seem to locate an answer.  Through my search, it seems many of the posts were from before the DD/MM/YYYY format became available.  My question is this:  Is there a way to format the dat to include the leading zero (for single digit days and months such as 08/02, for the eigth of February.  Anytime I see DD/MM/YYYY, I'm expecting it to read 2 digits/2 digits/4 digits.  I'm not sure if that's something I got used to in Microsoft Excel.  I thought it may be an Adobe convention, but Adobe Acrobat offers a number of formats that include the leading zero.  Any guidance would be greatly appreciated!

    This topic has been closed for replies.
    Correct answer Astro The Goat

    Please disregard my last reply.  I think I may have found it!  Thanks as always!


    The easiest way is just to use the modulus or "remainder" operator and divide the year by 100 i.e.

    yyStr = yyyy % 100;

     

    Or you could use the slice() function to get the last two digits of the year i.e.

    yyStr = yyyy.slice(-2);

    // Get the last two digits of the year

     

     

    1 reply

    Lilybiri
    Legend
    February 8, 2022

    Not sure to understand completely.  Are you talking about system variables? AFAIK they always have been available, but some of them have been added in version 6 which is quite a while ago. Have a look at this table with system variables:

    http://blog.lilybiri.com/discover-slash-use-captivates-system-variables-part-1

    Variables in Captivate are bit weird sometimes. You cannot calculate dates as is possible in Excel. That is the reason you have different formatting options in Captivate. One of them is based on the setup of dates on your system. Can you tell which exact system variable you are using?

     

    gcayton78
    gcayton78Author
    Known Participant
    February 8, 2022

    Sorry, let me explain.  The cpInfoCurrentDate format reads MM/DD/YYYY, so when I place that variable into a project, I'm expecting it to read 02/08/2022 for Febuary 8, 2022.  Instead it reads 2/8/2022, and is dropping the zero off of the month and the day.  I'm wondering if there is a way to create my own variable that would include the zero, since it does allow us to edit the system variables.  I have tried switching the format of my operating system, but it still ignores the zeroes.  I hope that explains my query a little better.

     

    Thank you.

    Lilybiri
    Legend
    February 8, 2022

    You will need JavaScript in that case. 

    You cna combine cpInfoCurrentDate with cpInfoCurrentMonth and cpInfoCurrentYear but you'll need to format the numbers using JS to keep it to 2 numbers both for Date and Month.