Search code examples
mixpaneljql

Querying by Date/Time in Mixpanel's JQL


Currently I am under the impression that when using mixpanel's JQL, one can only query by date in this format YYYY-MM-DD like so:

function main() {
  return Events({
    from_date: '2019-03-19',
    to_date:   '2019-03-20',
    event_selectors: [{ 'event': 'signup' }]
  });
}

This will return a JSON like this:

[
  {
    "name": "signup",
    "distinct_id": "1ce53208-e037-4c68-aac7-7a4e06d188a0",
    "labels": [],
    "time": 1451723182000,
    "sampling_factor": 1,
    "dataset": "$mixpanel",
    "properties": {
      "$email": "Elizabeth.Bryant@gmailx.com",
      "$import": true,
    }
  },
]

I'd like to know if it is possible to query not only by date but also by time using the default Mixpanel properties? I realize one option would be to add a custom property to the event when its triggered that contains the date-time but I'd like to avoid adding duplicate data unnecessarily since the JSON already contains the time timestamp property.


Solution

  • I have found the answer! Simply need to chain filter to the event like so:

    function main() {
      return Events({
        from_date: '2016-01-01',
        to_date:   '2016-01-07',
      }).filter(function(event) { return event.time >=  1451608507000 });
    }