0

I have an object I'm tracking in keen-io that has several date fields. I'd like Keen to preserve these as DateTime fields. This way I can do filtering and sorting.

I'm using a map add adding the dates formated as ISO-8601.

Map<String, Object> o = new HashMap<String, Object>();

o.put("deliveryDate", formatDate(deliveryDate));
o.put("completionDate", formatDate(completionDate));
o.put("assignedDate", formatDate(assignedDate));

Where formatDate looks like:

private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");

protected String formatDate(Calendar date) {
    return dateFormat.format(date.getTime());
}

When the events get to my keen dashboard the field is always treated as a string not a datetime.

Am I missing some step I can not find in the documentation? Are datetime fields available on fields other than keen.timestamp and keen.created_at?

Broonix
  • 1,135
  • 2
  • 11
  • 26

1 Answers1

2

Sadly, datetime is not one of the four inferred data types currently supported (https://keen.io/docs/api/#inferred-data-types). You are correct that they are only supported right now for keen.timestamp and keen.created_at. I passed along useful feedback to the Keen team on this use case.

One work around is converting your datetimes to seconds from epoch. It is not ideal, but it can work. It has some logic to it and will help you do queries. When you want to display the time, you will need to convert back to a readable string.

Hopefully this changes in the future!

tbarn
  • 348
  • 1
  • 9