Created
September 27, 2016 02:39
-
-
Save gcaraciolo/8bda1fddf7531ec4e90828a02b122736 to your computer and use it in GitHub Desktop.
Sequelize date_truc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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