Okay,
I want to convert column datetime to date while querying.
Can anyone help me out with sequelize query of below given query ?
select * from ev_events where DATE(event_date) <= '2016-10-10'
const TODAY = new Date(); const SUM = await OrdersModel. sum('price', { where: { created: Sequelize. DATE(TODAY), }, }); console. log(SUM);
$gt stands for "greater than". You could use $gte instead of $gt . $gte stands for "greater than or equal to".
You can use sequelize.fn
:
Event.findAll({
where: sequelize.where(sequelize.fn('date', sequelize.col('event_date')), '<=', '2016-10-10')
})
I've had to guess how you have defined your model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With