1

In cube js finding the count between days is not working for mysql database. Please help me to resolve. While calculating the balance days between....

measures: {
  balanceDays: 
    {
      type: count,
      sql: DATEDIFF(day, '${NmOrder.show_date}', '${NmOrder.booked_date}')   
    },
},

This is also not working

measures: {
      balanceDays: 
        {
          type: count,
          sql: TO_DAYS(${show_date}) - TO_DAYS(${booked_date}) 
        },
    },

2 Answers2

0

Don't need to mention MySQL keywords. Just simply like below

measures: {
      balanceDays: 
        {
          type: countDistinct,
          sql: show_date - booked_date 
        },
    },
avermaet
  • 1,543
  • 12
  • 33
Tech Key
  • 101
  • 2
0

This works for me.

measures: {
      balanceDays: 
        {
          type: `number`,
          sql: `DAY(${show_date} - ${booked_date})` 
        }
    },