Solved

Querying by DateTime in JQL

  • 21 March 2019
  • 2 replies
  • 45 views

Badge

Currently I am under the impression that when using JQL in mixpanel, one can only query by date in the 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 my own custom property to the event so that when it is triggered it contains the current date-time but I'd like to avoid adding duplicate data unnecessarily since the response already contains the `time` timestamp property.


icon

Best answer by michael 27 March 2019, 22:41

You're totally right, @kidpass!

Using the .filter() transformation you can filter between two specific timestamps, like so:

  .filter(function(event){
  return event.time >= 1553644800000 && event.time <= 1553644900000
  })

View original

2 replies

Badge

I believe I found my own answer. Simply use the .filter() method.


Userlevel 4
Badge +1

You're totally right, @kidpass!

Using the .filter() transformation you can filter between two specific timestamps, like so:

  .filter(function(event){
  return event.time >= 1553644800000 && event.time <= 1553644900000
  })

Reply