好吧,我只是将日期转换为大纪元,我正在从数据库中搜索某些字段。
我尝试将epochtime转换为bigint和string等。但仍然显示错误。
const getSleep =(request,response)=>{
startdate= request.params.startdate;
enddate=request.params.enddate;
var startEpoch = new Date(startdate);
var endEpoch=new Date(enddate);
startEpoch = (startEpoch.getTime()/1000)
endEpoch= (endEpoch.getTime()/1000)
pool.query('select * from sleep100 where wake_up_time between ($1) and ($2)',[startEpoch, endEpoch],(error,results)=>{
if(error){
throw error
}
response.status(200).json(results.rows);
})
}
这是以下错误。
Starting child process with 'node index.js'
/home/kakashi/workspace/dashboard/queries.js:89
throw error
^
error: invalid input syntax for integer: "NaN"
at Connection.parseE (/home/kakashi/workspace/dashboard/node_modules/pg/lib/connection.js:602:11)
at Connection.parseMessage (/home/kakashi/workspace/dashboard/node_modules/pg/lib/connection.js:399:19)
at Socket.<anonymous> (/home/kakashi/workspace/dashboard/node_modules/pg/lib/connection.js:121:22)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:607:20)
Program node index.js exited with code 1
Starting child process with 'node index.js'
console.log(开始日期)// 16-01-1997
console.log(enddate)// 1997年1月16日