C#MongDB数据库取某时间段内的数据
BsonDocument bsonDoc = new BsonDocument();
bsonDoc.Add("TimeData", new BsonDocument() { { "$gte", DateTimeToInt(StartTime) }, { "$lte", DateTimeToInt(EndTime) } });//StartTime,EndTime分别为起始时间和终止时间
var collection = MoDataBase.GetCollection<BsonDocument>(string.Format("{0}_{1}_Day", StatioID, PullutionID));
var sort = Builders<BsonDocument>.Sort.Ascending("TimeData");
var list = collection.Find(bsonDoc).Sort(sort).ToList();
/// <summary>
/// 将取到的时间转为Int
/// </summary>
/// <param name="datetime"></param>
/// <returns></returns>
private static BsonInt64 DateTimeToInt(string datetime)
{
return BsonInt64.Create(System.DateTime.Parse(datetime).ToString("yyyyMMddHHmmss"));
}
C#MongDB数据库取某时间段内的数据的更多相关文章
- Sqlite查询时间段内的数据问题解决!
最近搞Sqlite本地查询,需求为查询某时间段内的数据,在SQL中我们都知道为: select * from tblName where rDate Between '2008-6-10' and ...
- 数据库SQL语句查询指定时间段内的数据
[摘要]有的时候,我们需要查询数据库某段时间之间的数据,比如2016年5月1号到到5月3号之间用户注册数量(特殊节假日期间)等.那么用SQL语句如何实现呢? 首先,数据表中的存时间的字段比如是addt ...
- sql取指定时间段内的所有月份
declare @begin datetime,@end datetime set @begin='2017-01-01' set @end='2019-03-04' declare @months ...
- sql server取某个时间段内所有日期或者所有月份
取所有月份: declare @begin datetime,@end datetime set @begin='2015-2-6' set @end='2015-12-2' declare @mon ...
- Mybatis中如何查询时间段内的数据
最后一个是正确的,前边的三个是可能遇到的坑,给大家展示一下,如果不需要的,可以直接跳到最后看: 有时候我们需要查询一张表内一段时间内操作的数据,大家很容易就想到了 between ? and ? 这个 ...
- 23-python用BeautifulSoup用抓取a标签内所有数据
1.获取子标签: thr_msgs = soup.find_all('div',class_=re.compile('msg')) for i in thr_msgs: print(i) ...
- 删除某一BSC在某一时间段内的数据
DELETE FROM cdl_raw_do_12501_ztev8_sht_201509 WHERE call_start_time >= STR_TO_DATE( '2015-09-14 2 ...
- mysql查询时间段内的数据
https://blog.csdn.net/ls1645/article/details/79118464
- python3用BeautifulSoup用字典的方法抓取a标签内的数据
# -*- coding:utf-8 -*- #python 2.7 #XiaoDeng #http://tieba.baidu.com/p/2460150866 #标签操作 from bs4 imp ...
随机推荐
- nginx https 转发
add_header Content-Security-Policy upgrade-insecure-requests;
- WebGL学习笔记(十六):遮罩
这里总结下几种WebGL中实现遮罩的方法. 模板缓冲 模板缓冲可以实现渲染剔除,但是我们之前的学习里,剔除范围是基于上一次渲染的结果,且上一次的渲染也会进行显示,这样的话并不适合用来实现遮罩. 我们想 ...
- C语言 按位异或实现加法
/* C语言 按位异或实现加法 */ #include <stdio.h> #include <stdlib.h> #include <string.h> void ...
- 【GMT43智能液晶模块】例程二十二:USB_CDC实验——高速数据传输
源代码下载链接: 链接:https://pan.baidu.com/s/10KOWONWbNYlonyuX0W0Mcg 提取码:ggpo 复制这段内容后打开百度网盘手机App,操作更方便哦 GMT43 ...
- LeetCode_453. Minimum Moves to Equal Array Elements
453. Minimum Moves to Equal Array Elements Easy Given a non-empty integer array of size n, find the ...
- phpspreadsheet 中文文档(八)读写文件+读取文件
2019年10月11日14:09:40 配置设定 将PhpSpreadsheet文件包含在脚本中之后,但是在实例化Spreadsheet对象或加载工作簿文件之前,可以设置许多配置选项,这些配置选项将影 ...
- 领域模型/DDD领域驱动设计
http://www.fanyilun.me/2018/04/08/%E8%B0%88%E8%B0%88%E9%A2%86%E5%9F%9F%E5%BB%BA%E6%A8%A1/ http://www ...
- JS增删改查localStorage实现搜索历史功能
<script type="text/javascript"> var referrerPath = "@ViewBag.ReferrerPath" ...
- Dockerfile HEALTHCHECK健康检查
Dockerfile中使用HEALTHCHECK的形式有两种: 1.HEALTHCHECK [options] CMD command 2.HEALTHCHECK NODE 意思是禁止从父镜像继承的H ...
- 香农的伟大论文《A Symbolic Analysis of Relay and Switching Circuits》
香农在1938年发表的伟大论文A Symbolic Analysis of Relay and Switching Circuits(<对继电器和开关电路中的符号分析>)将开关.继电器.二 ...