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 7048405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:53:17+00:00 2026-05-28T02:53:17+00:00

Are the dates stored in the ‘created_at’ fields marshaled to Python datetime objects via

  • 0

Are the dates stored in the ‘created_at’ fields marshaled to Python datetime objects via PyMongo, or do I have to manually replace the text strings with Python Date objects? i.e.

How do I convert a property in MongoDB from text to date type?

It seems highly unnatural that I would have to replace the date strings with Python date objects, which is why I’m asking the question.

I would like to write queries that display the tweets from the past three days. Please let me know if there is a slick way of doing this. Thanks!

  • 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-28T02:53:17+00:00Added an answer on May 28, 2026 at 2:53 am

    you can parse Twitter’s created_at timestamps to Python datetimes like so:

    import datetime, pymongo
    created_at = 'Mon Jun 8 10:51:32 +0000 2009' # Get this string from the Twitter API
    dt = datetime.strptime(created_at, '%a %b %d %H:%M:%S +0000 %Y')
    

    and insert them into your Mongo collection like this:

    connection = pymongo.Connection('mymongohostname.com')
    connection.my_database.my_collection.insert({
        'created_at': dt,
        # ... other info about the tweet ....
    }, safe=True)
    

    And finally, to get tweets within the last three days, newest first:

    three_days_ago = datetime.datetime.utcnow() - datetime.timedelta(days=3)
    tweets = list(connection.my_database.my_collection.find({
        'created_at': { '$gte': three_days_ago }
    }).sort([('created_at', pymongo.DESCENDING)]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have birth dates stored as datetime in SQL Server 2008 like so: 2010-04-25
I have SQL Server 2005 and all dates are stored using a DATETIME column
I have a list of dates stored in MySQL using PHP. These were stored
I have a table with 5 million records of dates stored as char(10) with
I am using MS SQL Server 2005, I have dates stored in epoch time
When supplying dates to a stored procedure via a parameter I'm a little confused
I have high precision dates stored in an SQL server, e.g. 2009-09-15 19:43:43.910 However
I have a list of dd/mm/yyyy dates stored in a hash that I need
I have this situation where I am reading about 130K records containing dates stored
We all know dates are stored as YYYY-MM-DD. I have a search box that

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.