4 Replies Latest reply on Aug 1, 2015 11:45 AM by G. Singelmann

    Trouble with variable text data for date?

    tediousdesignworks Level 1

      Hi everyone!

      I have a problem figuring out the variable text data. I want to make an ascending date so I can print a daily log out for continuous use. I want it to start with today's date, and keep adding from there. Do I need to use a script for this? If so I have no knowledge of writing scripts.

        • 1. Re: Trouble with variable text data for date?
          G. Singelmann Level 3

          I am not sure that I understand your question.

           

          There is no text variable for the date "now/today". But there is something just as good: the date of last save or save-as.

           

          Iow: create and insert a variable for "changed" and do a save before you print or export. That should put today into your variable.

          • 2. Re: Trouble with variable text data for date?
            Sandee Cohen Adobe Community Professional

            Gerald,

             

            I thought about that as well as the output date.

             

            The problem is if he keeps entering additional paragraphs with a new text variable, all the paragraphs will switch to the latest Save or Output date.

            • 3. Re: Trouble with variable text data for date?
              BenCloutier Level 1

              You can copy the variable and then convert the variable to text. Paste the variable in the clipboard for todays entry.

              It is important to do nothing else before converting the variable to text.

              • 4. Re: Trouble with variable text data for date?
                G. Singelmann Level 3

                Sandee,

                ah, you think he wants all the dates in one story? That won’t work but for Ben’s suggestion.

                 

                I’d recommend a little script in that case:

                ------------------------------------

                var date = new Date();

                 

                 

                var year = date.getFullYear();

                var month = ("0" + (date.getMonth()+1)).substr(-2);

                var day = ("0" + date.getDate()).substr(-2);

                 

                 

                var date_string = year + "-" + month + "-" + day;

                 

                 

                if (app.selection && app.selection.length == 1 && app.selection[0].constructor.name == "InsertionPoint") {

                  app.selection[0].contents = date_string;

                }

                ------------------------------------

                 

                @OP:

                - copy that script into a text-only file.

                - in InDesign open Window > Utilities > Scripts

                - right click on "User" and select "Show in Finder/Explorer"

                - save the text-only file into that "Script Panel" folder

                - start the script either by doubleclicking in the script panel

                - or choose "Keyboard Shortcuts" in the Edit menu and assign a shortcut in the "scripts" section.

                 

                I wrote the script so that "2015-08-01" is inserted at the current insertion point. If you want eg. "01.08.2015" look at the line

                "var date_string = year + "-" + month + "-" + day;"

                and change that accordingly.

                 

                HTH

                1 person found this helpful