8
Views
2
Comments
[MongoDB] Datetime Conversion - Mongo DB to Outsystems
Forge component by Barduino
10
Published on 18 Feb 2021
Application Type
Traditional Web

Hi All,


I have been trying to get some data from mongo db to display on a outsystems app.
However, i always get an error on the date field when i try to convert the JSON object retruned to the outsystems object.

I already used the jsonDeserializer also the BSON toolkit from forge and no luck.
I have tried change the date formats at source but so far i have no luck with that either.

I have checked the sample app and it does not have a date field.
Did anyone manage to use this component sucessfully querying a collection with date fields?


Thanks in advance

Rank: #1914

Hi, 

Try using the standard date time in the source, may be it will work

EG: ({ $date: '2018-08-31T05:26:05+00:00'}  ) some thing like this.

hope it will work.

Thanks

Rank: #95

Hi Fernando,

MongoDB stores dates internally using unsigned 64 bit integer, representing the milliseconds since Unix epoch Jan 1 1970.

Although MongoDB shell and the driver does have a few functions to format the Unix time into something human readable those functions are useless for OutSystems. 

In order to use a date or date time there a few steps you have to do:

(Consider the demo app context)

Create a date time attribute on your structure

Set all your JSON Serialize/Deserialize to use the unix time translation






And you should be good


Cheers