Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6563515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:51:39+00:00 2026-05-25T13:51:39+00:00

This has been asked a lot, but I’m still facing some issues with it.

  • 0

This has been asked a lot, but I’m still facing some issues with it.

I have date I receive and was storing as Date. I need to query on Greater Than and Less than, so I changed it to Time, tried it again, but I’m getting weird results.

I’m doing this

Class.where(:event_date.gt => Time.parse(Date.today))

and I’m getting old records, 1940s, 1960s and others. I tried converting time by adding .utc at the end, comparing against Date.today only, but nothing sovled the problem so far. This is the selector being generated by Mongoid

selector: {:date_utc=>{"$gte"=>Sat Sep 10 21:00:00 UTC 2011}},

I receive the date in this format “2011-09-11” and store it in the Time field. Tried parsing that as Time utc as well, no luck.

Any idea? I’m using Mongoid 2.0.2. Later versions seem incompatible with other extensions I’m using.

[UPDATE]

So the problem is with the old dates before 1970 apparently. How do I deal with them is the question now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:51:40+00:00Added an answer on May 25, 2026 at 1:51 pm

    This is a known bug in Mongo. See ISSUE 405

    The reason is that Mongo uses an unsigned number to store dates, so anything before the epoch rolls over far into the future.

    Affortunately this issue has been fixed for stable version 2.0 released today. Upgrading to this version should solve your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this has been asked a lot, but I have a server-side custom
I know this has been asked a lot of times, but I have honestly
This question has been asked a lot here, but i still can't fix my
Maybe this question has been asked a lot, but I still can't understand how
This question has been asked a lot but everywhere the answers fall short. I
I fully understand this question has been asked a lot , but I'm asking
Well I guess this has been asked a thousand times, but for some reason
I know this sort of question has been asked before , but I still
This question has been asked a lot of times in many forums. But I
I know this has probably been asked a lot on here, but I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.