Skip to main content
Question

Mongodb and date format


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

6 replies

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

Precision: insert with Document source= Json attribute


takashi
Influencer
  • 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+50
  • 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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings