5 Replies Latest reply: Jan 19, 2018 3:27 PM by Mo Abdolrahim RSS

    Macro to adjust date on input file

    Melissa Falardeau

      I am using the Monarch Server Automator version 14.1 to run a process.  This process uses a project that looks for an import file with naming that looks like this:

       

      OTD.DRAFT.TAPE1801042204 

      the numbers are the 2 digit year-month-day-time. 18-year 01-month 04-day 2204-time   I have the project set to look for:

       

      OTD.DRAFT.TAPE&[yy]&[mm]&[dd]*  this allows it to pick up a file that matches todays date.

       

      What I need is it to pick up a file with yesterdays date.  I have tried adjusting the macros by -1 from each

       

      OTD.DRAFT.TAPE&[yy-d]&[mm-d]&[dd-d]*    This ended up working but picked up everyday before today that was in the file

       

      I also tied just -1 on the day  OTD.DRAFT.TAPE&[yy]&[mm]&[dd-1]*  This picked up everyday before today that is in the same month and year

       

      How can I adjust the macro to only pick up yesterdays file?  I do need to take into consideration that on 01-01-19 I need to pick up 12-31-18

       

      Thank you!

        • Re: Macro to adjust date on input file
          Mo Abdolrahim

          To pick up previous day file using a macro use the following syntax:

          previous day: &[yy]&[mm]&[dd.-1d]

          Previous month: &[yy]&[mm.-1m]&[dd]

          Previous year: &[yy.-1y]&[mm]&[dd]

          However when the month changes, the syntax should be &[yy]&[mm.-1m]&[dd.-1d]

          When the year changes, the syntax should be &[yy.-1y]&[mm.-1m]&[dd.-1d]

          I suggest you copy the input file to a folder, and use a wild card character, e.g OTD.DRAFT.TAPE*

          Regards

          Mo

            • Re: Macro to adjust date on input file
              Grant Perkins

              Mo,

               

              What would be really great here would be an option to work with the current date, as one can in Monarch for example, and specify a number of days, months, years, or whatever to change it by. Then convert the result to the format used to select the report.

               

              Any possibility of proposing that to the developers?

               

              I guess it could be scripted or processed separately (based on a User input field at run time?) and the result brought in somehow but so much easier if it could be applied directly.

               

               

              Melissa,

               

              If it is safe to assume that all of the reports in the folder with name the same other than the date part  are consistent for processing by this routine (I am assuming you may have several reports here in some situations but realise you might just be needing a formula that picks up "yesterday's" file for processing today)  .... then you also have the option of processing every file and filtering the results.

               

              If you need to allow for, perhaps, deferred processing because reports are not presented each day of a weekend,say, or systems have been taken out of action for maintenance or some other example, then running a mass process once for a black of reports and filtering the results for output may be a good approach anyway. It would also provide for easy recovery in the event that something goes wrong with the process somewhere and the auto run fails or the distribution fails (email system down for example) and re-running would be the simplest way to resolve things.

               

              Just a few thoughts to add to possibilities.

               

               

              Grant

            • Re: Macro to adjust date on input file
              pleen

              Hello,

               

              I use the yesterday's date macro for most of my processes in Automator as we need the end of day file for yesterday. The macro is what you have above but with a period in before the "-d", not sure if you have that in Automator or that just wasn't typed here.

              OTD.DRAFT.TAPE&[yy.-d]&[mm.-d]&[dd.-d]*