Search code examples
sqlcube.js

How to format time-type data with mongodb and cubejs?


I found this url about this topic:

I didnt found the format for time-type. So I try to use sql: PARSE_TIMESTAMP('%Y-%m-%d', date)

    createdat: {
      sql: `PARSE_TIMESTAMP('%Y-%m-%d',${CUBE}.\`createdAt\`)`,
      type: `time`
    },

it will return a error:

Error: Error: scalar function 'parse_timestamp' is not supported

Solution

  • createdat: {
        sql: `DATE(${CUBE}.\`createdAt\`, '%Y-%m-%d')`,
        type: `time`
    },
    

    Thanks