Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3280

Query between month and day of current date

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Hi I am using version 3.1.4 and wanted to get all records between month and day range of current date without year.
      For example ,I have a Event model
      Class Event
      include Mongoid::Document
      field :name
      field :start ,type: Date
      field :end ,type: Date
      end
      I want to get all the records occurring between today without year.
      for example I have 6 records in DB
      start=>2013-Sep-15 ,end: => 2013-Oct-10
      start=>2013-Sep-10 ,end: => 2013-Oct-01
      start=>2013-Sep-18 ,end: => 2013-Dec-12
      start=>2013-Sep-15 ,end: => 2013-Oct-10
      ---* not current year
      start=>2012-Sep-15 ,end: => 2012-Oct-10
      start=>2011-Sep-15 ,end: => 2012-Jan-10

      Event.where(:start.lte=>Date.to_day,:end.gte=>Date.to_day) will return first 4 records but rest of two are ignored.
      I want to get rest of the records because today(month and day) also matching with month and day of those.

      Any idea how i can do that using mongoid?

            Assignee:
            Unassigned Unassigned
            Reporter:
            maisaengineering maisaengineering
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: