如何查找统计日期和结束日期之间的日期
How to find date between stat date and end date
我在数据库 start_date 和 end_date 中有两个字段。
如何查找我传递的日期是否在这两个日期之间。
型号
class Schedule
include Mongoid::Document
field :start_date, type: Date
field :end_date, type: Date
end
简单的 activerecord 查询是
Schedule.where(["start_date <= ? AND end_date >= ?", params[:date], params[:date] ])
日期以下列格式保存在数据库中
{
"_id" : ObjectId("559d182f6368611dbf000000"),
"start_date" : ISODate("2015-06-10T00:00:00.000Z"),
"end_date" : ISODate("2015-07-10T00:00:00.000Z")
}
我的参数包含日期,如“2015-06-10”
将 MongoDB 数据库与 Mongoid 一起使用时会有什么查询?
这应该有效
Schedule.where(:start_date.lte => date, :end_date.gte => date)
我在数据库 start_date 和 end_date 中有两个字段。 如何查找我传递的日期是否在这两个日期之间。
型号
class Schedule
include Mongoid::Document
field :start_date, type: Date
field :end_date, type: Date
end
简单的 activerecord 查询是
Schedule.where(["start_date <= ? AND end_date >= ?", params[:date], params[:date] ])
日期以下列格式保存在数据库中
{
"_id" : ObjectId("559d182f6368611dbf000000"),
"start_date" : ISODate("2015-06-10T00:00:00.000Z"),
"end_date" : ISODate("2015-07-10T00:00:00.000Z")
}
我的参数包含日期,如“2015-06-10”
将 MongoDB 数据库与 Mongoid 一起使用时会有什么查询?
这应该有效
Schedule.where(:start_date.lte => date, :end_date.gte => date)