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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:48:41+00:00 2026-06-06T23:48:41+00:00

I currently have a collection with documents like the following: { foo: ‘bar’, timeCreated:

  • 0

I currently have a collection with documents like the following:

{ foo: 'bar', timeCreated: ISODate("2012-06-28T06:51:48.374Z") }

I would now like to add a timestampCreated key to the documents in this collection, to make querying by time easier.

I was able to add the new column with an update and $set operation, and set the timestamp value but I appears to be setting the current timestamp using this:

db.reports.update({}, { 
    $set : { 
        timestampCreated : new Timestamp(new Date('$.timeCreated'), 0) 
    } 
}, false, true);

I however have not been able to figure out a way to add this column and set it’s value to the timestamp of the existing ‘timeCreated’ field.

  • 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-06-06T23:48:42+00:00Added an answer on June 6, 2026 at 11:48 pm

    Do a find for all the documents, limiting to just the id and timeCreated fields. Then loop over that and generate the timestampCreated value, and do an update on each.

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

Sidebar

Related Questions

I have a MongoDB collection called employees where there are documents like this: {
I currently have a collection of documents that each contain arrays pointing at other
I'm using pymongo and currently have a single collection. The collection holds documents representing
We are currently implementing a solution where we have a collection which we want
Currently have password protection on my main and sub directories, however I'd like to
I have a slowly growing collection of about 3 million tagged documents and I
I have the following situation: excel-like application, that is accessible from internet. 2 users
I currently have a MongoDB setup with a fairly large database (about 250m documents).
I have a collection of beans OptionItemDTO (properties label and value) and I'm currently
Suppose I have a large (300-500k) collection of text documents stored in the relational

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.