title: Sequelize function on where
body: <p>I using sequelize 5.21.2 on Node 12.</p>
  <p>I want to get like this:</p>
  <pre><code>SELECT `id`
  FROM `order`
  WHERE (substr(`order`.`code`,1,8) &gt;= '20200101'
  AND substr(`order`.`code`,1,8) &lt;= '20201230')
  </code></pre>
  <p>So I wrote it like this:</p>
  <pre><code>return Model.order.findAll({
    attributes: [
      'id',
    ],
    where: {
      [sequelize.fn('substr', Model.sequelize.col('code'), 1, 8)]: {
        [Op.gte]: params.start_date,
        [Op.lte]: params.end_date,
      },
    },
  });
  </code></pre>
  <p>But It returns:</p>
  <pre><code>SELECT `order`.`id`
  FROM `order`
  WHERE (`order`.`[object Object]` &gt;= '20200101'
  AND `order`.`[object Object]` &lt;= '20201230')
  </code></pre>
  <p>I tried</p>
  <pre><code>[sequelize.literal('STR_TO_DATE(substr(code,1,8),\'%Y %m %d\')'), 'order_date']
  [sequelize.literal('STR_TO_DATE(substr(code,1,8),\'%Y %m %d\')')]
  [sequelize.fn('substr', Model.sequelize.col('code'), 1, 8)]
  </code></pre>
  <p>but they work fine when I <code>SELECT</code>, but not <code>WHERE</code>.</p>
  <p>How do I get the results I want? I couldn't find any relevant information in the official manual.. (<a href="https://sequelize.org/v5/manual/querying.html#where" rel="nofollow noreferrer">https://sequelize.org/v5/manual/querying.html#where</a>)</p>