节点js postgres选择查询不适用于没有区域的时间戳

问题描述

无法使用NODE JS中没有时区的时间戳从postgres db中获取结果。

下面是查询

节点代码:

    var currentDateTime = new Date()
    var MS_PER_MINUTE = 60000;
    var myStartDate = new Date(currentDateTime - 5 * MS_PER_MINUTE);

var query = {
                name: 'fetch-devices-in-last',text: 'SELECT ipscan.location_id,count(DISTINCT(ipscan.client_device_id)) as noofdevices  from ipscans ipscan JOIN location_ap_map locmap ON ipscan.location_id = locmap.location_id  where ipscan.modified_datetime between $1 AND $2 group by ipscan.location_id',values: [myStartDate,currentDateTime]
}

查询值

{"name":"fetch-devices-in-last","text":"SELECT ipscan.location_id,count(DISTINCT(ipscan.client_device_id)) as noofdevices  from ipsca
ns ipscan JOIN location_ap_map locmap ON ipscan.location_id = locmap.location_id  where ipscan.modified_datetime between $1 AND $2 group by ipscan.location_id","values":
["2020-09-22T20:00:00.017Z","2020-09-22T20:05:00.017Z"]}

如果在db中执行相同的查询,则它将返回数据,但不是从节点js返回。甚至我都尝试过在日期时间之间使用“ 5分钟”的间隔,但这不起作用。

修改后的日期时间列类型为不带时区的时间戳,样本值为“ 2020-04-19 21:28:20”

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...