Search code examples
mixpanel

How do you reference today's date in Mixpanel JQL API?


event = "function main(){return Events({from_date: '2020-11-01', to_date: ... , event_selectors: [{event:'Search'}]}).groupByUser(['properties.Completion'], mixpanel.reducer.count())}"

What should I put after "to_date" to pull automatically pull today's date?


Solution

  • You can add a variable for today like in the following example:

    function main() {
       //Get today's date
      var today = new Date ( (new Date())).toISOString().split('T')[0];
      return Events({
        from_date: '2020-11-01',
        to_date:   today,
      })
      .groupByUser(['properties.Completion'], mixpanel.reducer.count());
    }