SPSS Modeler

 View Only
Expand all | Collapse all

Converting ISO8601 date time String to a datetime variable to use in models an change time zones

  • 1.  Converting ISO8601 date time String to a datetime variable to use in models an change time zones

    InnerCircle
    Posted Mon October 18, 2021 09:50 AM
    Hello:

    I ask for your help I have the following ISO8601 timestamp from my logs for example 2021-09-22T14:50:51.546709787Z
    the data comes form a CSV file.

    I need to complete two tasks:
    1.- Convert it to date time variable so I can use it in the rest of the model as a date object so I can aggregate by hour or 15min intervals
    2.- Also change the time zone, as the time was recorded as UTC and I need to change it to Central Time

    There must be an automatic way of doing this but I am new to the product.  I have gone thru de documentation I only found this functions date_iso_year(DATE)

    Appreciate any help

    Kind regards

    ------------------------------
    ANTONIO AROCHA
    Walmart Central America IT
    ------------------------------


  • 2.  RE: Converting ISO8601 date time String to a datetime variable to use in models an change time zones

    Posted Tue October 19, 2021 09:22 AM
      |   view attached

    Hi Antonio,

    I have attached a zip file that contains two SPSS Modeler stream files, Date Nodes.str and Timestamp Creation.str.

    Timestamp creation contains an example of how you would convert the ISO8601 timestamp to a timestamp in SPSS Modeler.  In the example, I used three separate Derive Nodes, however, you could do this in a single node.  You could also use a Filler node to do the same thing but replace the existing field's values with the Modeler timestamp value.  Note that you will lose the milliseconds as the timestamp deals with seconds as integers.  In my example, I extracted the date portion of the time stamp and created a Modeler date field.  Next, I extracted the hour, minutes, seconds and created a Modeler time field.  I then combined the two to create a Modeler timestamp field.

    The Date Nodes.str contains multiple examples of how you can create and manipulate dates and times in Modeler.

    Regards,
    David West
    westd@us.ibm.com



    ------------------------------
    DAVID WEST
    ------------------------------

    Attachment(s)

    zip
    Dates.zip   8 KB 1 version