Skip to main content

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

Precision: insert with Document source= Json attribute


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"}
}

 


It works. Thank you very much !


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 !!


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


Thank you for your response

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


Reply