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'
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.
sequelize.and(
{id: '111'},
sequelize.where(
sequelize.fn('date', sequelize.col('event_date')),
'<=', '2016-10-10'
)
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.