DEV Community

Mukit, Ataul
Mukit, Ataul

Posted on

3 2

MYSQL Query With Timestamp Long Values


function MySQLTimeStampCompatibleString(timestamp){
    return new Date(timestamp).toISOString().substring(0, 19).replace('T', ' ');
}
   
function queryWithTimestampLongValues(fromTime, toTime) {

    var query = "";    

    if(fromTime && toTime){      

        query += 'SELECT * FROM user_info WHERE 
                   user_info.created_at > TIMESTAMP("' +     
                   MySQLTimeStampCompatibleString(fromTime) + '") AND 
                   user_info.created_at < TIMESTAMP("' + 
                   MySQLTimeStampCompatibleString(toTime) +  '")';
    

    }

    return query;
}   

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (0)

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay