Script to Automate Current Date Import

I have a client that would like to automate the process of updating the current date in their Date Attribute module.

Are their any scripts available to auto-generate the current date to load into their module?  Ideally, we would install and use Anaplan Connect.

 

Thanks,

Tony

Best Answer

  • tonybomm
    Answer ✓

    Mike/Rob,

    Thanks a lot for the reply.  I don't believe they are currently importing any other data from a RDMS, but i will double check and present them with both options.

     

    Mosty likely go with the Anaplan Connect option.

     

    Thanks! 

    Tony

Answers

  • I find the simplest way is to get the date from a relational database by jdbc SQL query.  Each database engine has its own way of giving the current date, here are a few of the more common ones:

    Oracle PL/SQL:

    SELECT TO_CHAR(SYSDATE, 'mm/dd/yyyy') FROM DUAL

    SQL Server:

    SELECT CONVERT(VARCHAR(10), GETDATE(), 101) AS [MM/DD/YYYY]

    IBM Netezza:

    select TO_CHAR(current_timestamp,'MM/DD/YYYY')

    MySQL:

    select CURDATE()

    returns YYYY-MM-DD (text) or YYYYMMDD (number) format

     

    "Simple" is a relative term. This does require getting a server to run AC upon, getting database access, downloading the jdbc driver for the relational database from that vendor, installing Java and Anaplan Connect, setting up the AC script, and scheduling the job to run daily. If you are importing other data using SQL, then adding a "get today's date" job is trivial.  




  • If you don't have access to a RDMS like Mike referred to in the above, this is a way to do it through Anaplan Connect (shell script style).

     

    #Variable for file that gets updated with today's date and time
    DateAndTimeFileNm=${DATA_DIR}/System_Date.csv
    DateAndTimeFileName="System_Date.csv"

    #These are your Anaplan Commands
    Operation="-certificate ${Cert} -file ${DateAndTimeFileName} -put ${DateAndTimeFileNm} -import 'Load System Date from System_Date.csv' -execute"
    #Operation="-certificate ${Cert} -A"

    #Variable to designate folder path for Anaplan CLeint
    #AnaplanClientLocation="../../AnaplanClient.sh" #Add '../' before AnaplanClinet.sh to put you in the right folder based on where this script lives

     

    #____________________________ Do not edit below this line ______________________________
    #This Variable pulls current date from computer and converts it into Anaplan Date Format
    mydate=$(date +"%Y-%m-%d %T")
    # These lines write the current date and a header to the filename specified
    touch ${DateAndTimeFileNm}
    echo "Date and Time"> ${DateAndTimeFileNm}
    echo "${mydate}">> ${DateAndTimeFileNm}

     

     

    Hope this helps,

     

    Rob