Search code examples
javascriptmysqlnode.jsknex.js

Knex/Node/MySQL from YYYY-MM-DD HH-MM-SS to just YYYY-MM-DD


I would like to remove the time aspect from the date when retrieving it from the database, this is the code that I have for it but it isn't functional, could someone tell me where I went wrong?

.whereRaw('DATE_FORMAT( ap_meeting.horodate, "%Y-%m-%d" )' = conditions.dateMax)

Some context:

    var dateTime = new Date();
    dateMin = moment(dateTime).format("YYYY-MM-DD");
    dateMax = moment(dateMin).add(48, 'hours').format("YYYY-MM-DD");

Solution

  • Just wanted to make the answer nice and clear for all, thank you Nick for the speedy and on point reply!

    .whereRaw('DATE_FORMAT( ap_meeting.horodate, "%Y-%m-%d" ) = \'' + conditions.dateMax + '\'')