如何在给定日期转储数据 [英] How do I dump data for a given date

查看:71
本文介绍了如何在给定日期转储数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mongoexport导出给定日期的数据.我的命令是这样

mongoexport -d project -c coll  --csv -o result -f source -q '{"date":{"$gte":"new Date(2011,1,25)","lt":"new Date(2011,2,26)"}}'

但是它没有导出结果...我在数据库中存储了2011年2月25日和2011年2月26日的数据.如何查询日期?

解决方案

我遇到了同样的问题.

您可以在这里查看 http://www.epochconverter.com/

我正在使用Java ..所以我使用了

日期x =新日期(年,月,日)

并使用x.getTime()获取了纪元,并将其发送到mongoexport

所以您的mongo出口声明会是

mongoexport -d项目-c coll --csv -o结果-f源-q'{"date":{$ gte:(Date(1295913600)),$ lt:(Date(1298678400)}}''

I am using mongoexport for exporting data for a given dates..my command is this

mongoexport -d project -c coll  --csv -o result -f source -q '{"date":{"$gte":"new Date(2011,1,25)","lt":"new Date(2011,2,26)"}}'

but it is not exporting result...i have data stored for 25-feb-2011 and 26-feb-2011 in database..how do I query for dates?

解决方案

I had the same problem.. I fixed it by using the epoch time..

You can check here http://www.epochconverter.com/

I was using java .. so i used

Date x = new Date (year, month, day)

and got the epoch using x.getTime() and sent it to mongoexport

so ur mongo export statement would be

mongoexport -d project -c coll --csv -o result -f source -q '{"date":{$gte:(Date(1295913600)),$lt:(Date(1298678400)}}'

这篇关于如何在给定日期转储数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆