How to make a SELECT with CONVERT or CAST in the WHERE clause using sequelize

Asked

Viewed 371 times

1

I need to select below using sequelize.

SELECT COUNT(*) AS 'Count'
FROM Table
WHERE 
    CAST(DatetimeField AS DATE) = CAST(GETDATE() AS DATE)

So far I’ve managed to do using between but it’s not the best way to do it:

return model.findAll({
    attributes: [
        [sequelize.fn('COUNT', sequelize.col('*')), alias]
    ],
    where: {
        CreationDate: {
            $between: ['2017-09-15 00:00:00', '2017-09-15 23:59:59']
        }
    }
});

Can help?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.