Automic Workload Automation

  • 1.  CONV_DATE does not accept date format YYYY_MM_DD_d

    Posted Aug 15, 2016 11:25 AM
    I’m writing a bit of AE scripting to check whether a desired job start time is between the current time and midnight, so that I know if a day must be added to the start date before executing the job. Here is the code:
    :SET &START_TIME# = "03:10"
    :SET &START_DATE# = "&$PHYS_DATE_YYYYMMDD#"
    :PRINT "Today's date         : &START_DATE#"
    :SET &TIME_UNTIL_MIDNIGHT# = SUB_TIME("HH:MM;00:00","HH:MM;&$PHYS_TIME_HH_MM#","HH")
    :SET &TIME_UNTIL_START#    = SUB_TIME("HH:MM;&START_TIME#","HH:MM;&$PHYS_TIME_HH_MM#","HH")
    :PRINT "Time until midnight  : &TIME_UNTIL_MIDNIGHT#"
    :PRINT "Time until job start : &TIME_UNTIL_START#"
    :IF &TIME_UNTIL_MIDNIGHT# < &TIME_UNTIL_START#
    :  PRINT "Start time in current calendar day has already passed. Job will start tomorrow."
    :  SET &START_DATE# = ADD_DAYS("YYYYMMDD;&START_DATE#","1")
    :ENDIF
    :SET &START_DATE# = CONV_DATE("YYYYMMDD;&START_DATE#","YYYY_MM_DD_d")
    :PRINT "Job start date       : &START_DATE#"
    When I run this script, the AE returns a runtime error:
    8/15/2016 17:15:55 -  U00020341 Runtime error in object 'UC0.MAL.COMPARE_TIMES.SCRI', line '00017'. The format of date/period 'YYYY_MM_DD_D' is invalid.
    It seems the CONV_DATE doesn’t like the date format YYYY_MM_DD_d. This date format is documented in the list of Date and Time Formats, and this specific format is required by http://docs.automic.com/documentation/AE/11.2/english/AE_WEBHELP/help.htm#ucaafh.htmACTIVATE_UC_OBJECT (specifically, in the Start time parameter).

    Am I doing something wrong, or might this be a bug?


  • 2.  CONV_DATE does not accept date format YYYY_MM_DD_d

    Posted Aug 15, 2016 12:28 PM
    I think that you may be confusing date formats allowed by CONV-DATE with those that are available as predefined variables for system and object values.

    If you take the link to the date format in the CONV-DATE help it does not show the suffixed "_d" as an allowable format.


  • 3.  CONV_DATE does not accept date format YYYY_MM_DD_d

    Posted Aug 16, 2016 05:51 AM
    Yup, I had not noticed that the date formats differed. Here is the corrected script:
    :SET &START_TIME# = "03:10"
    :PRINT "Today's date         : &$PHYS_DATE_YYYY_MM_DD_d#"
    :SET &START_DATE# = "&$PHYS_DATE_YYYYMMDD#"
    :SET &TIME_UNTIL_MIDNIGHT# = SUB_TIME("HH:MM;00:00","HH:MM;&$PHYS_TIME_HH_MM#","HH")
    :SET &TIME_UNTIL_START#    = SUB_TIME("HH:MM;&START_TIME#","HH:MM;&$PHYS_TIME_HH_MM#","HH")
    :PRINT "Time until midnight  : &TIME_UNTIL_MIDNIGHT#"
    :PRINT "Time until job start : &TIME_UNTIL_START#"
    :IF &TIME_UNTIL_MIDNIGHT# < &TIME_UNTIL_START#
    :  PRINT "Start time in current calendar day has already passed. Job will start tomorrow."
    :  SET &START_DATE# = ADD_DAYS("YYYYMMDD;&START_DATE#","1")
    :ENDIF
    :SET &START_DATE# = CONV_DATE("YYYYMMDD;&START_DATE#","YYYY-MM-DD")
    :PRINT "Job start date       : &START_DATE#"
    And here’s the output:
    Today's date         : 2016-08-16
    Time until midnight  : 0000000012
    Time until job start : 0000000015
    Start time in current calendar day has already passed. Job will start tomorrow.
    Job start date       : 2016-08-17
    Thanks, Mark_Hadler_430 !