parseDate bug?

Comments

5 comments

  • Official comment
    Avatar
    Nick

    Hey Corbin,

    This is because Sumo's datetime parsing supports down to milliseconds (ss.SSS), not to the microsecond (ss.SSSSSS) as you have written in your query. So for example, here is a query that would truncate your dates and return an appropriate number:

    *
    | limit 1
    | formatDate(toMillis(parseDate("2017-10-06T14:36:48.243Z", "yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'")), "MM/dd/yyyy hh:mm:ss.SSSSSS") as date_millis
    | formatDate(toMillis(parseDate("2017-10-06T14:36:48.244Z", "yyyy-MM-dd'T'HH:mm:ss.SSSSS'Z'")), "MM/dd/yyyy hh:mm:ss.SSSSSS") as date_millis2

    Or, more similarly to yours:

    *
    | limit 1
    | toMillis(parseDate("2017-10-06T14:36:48.243Z", "yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'")) as date_millis
    | toMillis(parseDate("2017-10-06T14:36:48.244Z", "yyyy-MM-dd'T'HH:mm:ss.SSSSS'Z'")) as date_millis2

    Which returns 

    1,507,325,808,243


    1,507,325,808,244

    You would either have to truncate or round your milliseconds to fit them into the supported precision level.

    Let me know if this helps.

    Thanks,
    Nick

    Comment actions Permalink
  • Avatar
    Corbin Phelps

    Thanks Nick, that makes total sense. I'll adjust my query to handle that.

    I don't know if it's ideal behavior to give a completely wrong number back if the date I put in is past the millisecond precision that is supported. I think an error would be more ideal as right now it's not apparent that things are not working correctly without inspecting each conversion.

    0
    Comment actions Permalink
  • Avatar
    Nick

    Hi Corbin,

    I agree - I plan on filing a Jira for this and will post back here once I do that.

    Thanks,

    Nick

    0
    Comment actions Permalink
  • Avatar
    Nick

    Hi Corbin - I've gone ahead and entered a ticket for this bug. Thank you for identifying this!

    0
    Comment actions Permalink
  • Avatar
    Corbin Phelps

    Thanks for following up!

    0
    Comment actions Permalink

Please sign in to leave a comment.