Skip to content

Instantly share code, notes, and snippets.

@gcaraciolo
Created September 27, 2016 02:39
Show Gist options
  • Save gcaraciolo/8bda1fddf7531ec4e90828a02b122736 to your computer and use it in GitHub Desktop.
Save gcaraciolo/8bda1fddf7531ec4e90828a02b122736 to your computer and use it in GitHub Desktop.
Sequelize date_truc
var startAt = '2016-08-09';
var id = 1;
Model.find({
where: {
$and: [
{
id: id
},
sequelize.where(
sequelize.fn('date_trunc', 'day', sequelize.col('date')),
' = ',
sequelize.fn('date_trunc', 'day', sequelize.cast(startAt, 'TIMESTAMP'))
)
]
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment