Skip to main content
Question

Mongodb and date format

  • January 25, 2020
  • 6 replies
  • 98 views

pg.souque
Forum|alt.badge.img

Hi,

When i insert with the jsontemplater a date in the mongodb writer the type of date is always string even i choose isodate, fmedate......etc. Can i have a type date in mongodb via the jsontemplater ?

 

Thanks a lot

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

pg.souque
Forum|alt.badge.img
  • Author
  • January 25, 2020

Precision: insert with Document source= Json attribute


takashi
Celebrity
  • January 25, 2020

Hi @pg.souque, according to the MognoDB Extended JSON specifications, an object with this format represents a value with date type.

{"$date": "<ISO-8601 Date/Time Format>"}

It seems that the ISO Date/Time has to be UTC date/time ending with the timezone suffix 'Z'. For instance, try inserting this JSON text into a MongoDB collection.

{
    "event_name" : "FME World Tour 2020",
    "kick_off" : {"$date" : "2020-03-10T10:00:00Z"}
}

 


pg.souque
Forum|alt.badge.img
  • Author
  • March 2, 2020

It works. Thank you very much !


pg.souque
Forum|alt.badge.img
  • Author
  • November 24, 2023

Hello,

I have now this problem

How to convert a format $date from mongodb ?

The reader had for example this format: "date":{"$date":1337904000000}

In studio 3t format is for example 2012-05-25T00:00:00.000Z

I can't tranform "$date":1337904000000 with DateTimeConverter...

Help !!


geomancer
Evangelist
Forum|alt.badge.img+60
  • Evangelist
  • November 24, 2023

According to the Mongodb documentation, they use something called theBSON Date data type, which is a 64-bit integer representing the number of milliseconds since the Unix epoch, which was 00:00:00 UTC on 1 January 1970.

With this information, you can calculate the correct date.

image


pg.souque
Forum|alt.badge.img
  • Author
  • November 24, 2023

Thank you for your response

I tried with delete the 3 last characters (000) and format %s$....it works, thank you very much