sequelize date format
model.findAll({
attributes: [
'id',
[sequelize.fn('date_format', sequelize.col('date_col'), '%Y-%m-%d'), 'date_col_formed']
]})
.then(function(result) {
console.log(result);
});
sequelize date format
model.findAll({
attributes: [
'id',
[sequelize.fn('date_format', sequelize.col('date_col'), '%Y-%m-%d'), 'date_col_formed']
]})
.then(function(result) {
console.log(result);
});
sequelize date format
function getDateWithoutTime(date) {
return require('moment')(date).format('YYYY-MM-DD');
}
Sequelize date format
/*
* Copy this file to ./sscce.js
* Add code from issue
* npm run sscce-{dialect}
*/
var Sequelize;
var DataTypes = Sequelize = require('./index');
var sequelize = require('./test/support').createSequelizeInstance({
logging: console.log
});
var Topic = sequelize.define('topic', {
last_date_time: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.NOW
}
});
return sequelize.sync({
force: true
}).then(() => {
return Topic.update(
{
last_date_time: '2016-08-09 04:05:02',
},
{
where: {id: 42}
}
);
})
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us