Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-874

Mongoimport $date close to epoch not working

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.7, 3.0.7
    • Affects Version/s: 3.0.5
    • Component/s: mongoimport
    • None
    • Environment:
      Debian 7
    • Kernel Tools 8 08/28/15

      Hi,

      I'm working on importing data with dates before and after epoch.
      I use a timestamp (ms) with $date like this :

      {"date":{"$date":1287205428000}}
      

      It works great, gives me a document like this :

      {
      	"_id" : ObjectId("55ca240b026ec36b031a720c"),
      	"date" : ISODate("2010-10-16T05:03:48Z")
      }
      

      It also works great with negative timestamps (before epoch).

      However, I ran into some timestamps that created problems.
      For timestamps corresponding to dates between 1969-12-07 and 1970-01-25, mongoimport will throw this exception :

      Failed: error getting extended BSON for document #0: invalid type for $date field
      

      The document used to generate this error is :

      {"date":{"$date":2136800000}}
      

      or

      {"date":{"$date":-2136800000}}
      
      mongoimport -d test -c test --drop < date.json
      

      Fyi, with this timetamp (juste a day after) it's working :

      {"date":{"$date":2236800000}}
      

      I didn't find any other ticket about this specific problem.

      Regards

            Assignee:
            shraya.ramani Shraya Ramani
            Reporter:
            b.dieder@prismamedia.com Bastien Diederichs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: