how to convert time from one format to another

Comments

3 comments

  • Official comment
    Avatar
    Ryan Johnson

    Sumo Logic have operators to help with this, namely parseDate and toMillis.

    Using your example, this might look something like this:

    | toMillis(parseDate(delay_time, "mm:ss:SS")) as epoch_millis

    You can see some examples of their usage in our docs at Sumo DocHub: Compare Log Messages by Day of the Week

    Comment actions Permalink
  • Avatar
    Developers

    I have logs that include hours/minutes/seconds with 7 decimal places e.g. 00:00:29.0000366 and I needed to convert it to numeric values to do some group operations.
    The only way I found is to truncate to 3 decimal places, then call parseDate and toMillis function, and additionally subtract by magic 28800000.

    Does better way exist? What is the magic 28800000 ?

    | substring(publishTime, 0, 12) as strTime //leave only 3 decimal points
    | (toMillis(parseDate(strTime, "HH:mm:ss.SSS")) -28800000 )as millisec
    1
    Comment actions Permalink
  • Avatar
    Tommy Petersen

    28800000 is 8 hours converted to milliseconds.  

    0
    Comment actions Permalink

Please sign in to leave a comment.