I have tried to load date field into MongoDB via JSON file but I'm getting error as write erros:
{BulkWriteError{index=0,code-52,message='The doller($) prefixed field '$date' in 'ExpirationDate.$date' is not a valid for storage.'
Tried below methods, none of them are worked:
"ExpirartionDate":{
"$date":"2020-07-07"
}
"ExpirartionDate":ISODate("2020-0-07")
"ExpirartionDate":{ISODate("2020-0-07")}
Please advise correct format to insert date as ISO date in MongoDB via JSON file.
From the official documentation:
{"$date": {"$numberLong": "<millis>"}}{"$date": "<ISO-8601 Date/Time Format>"}{"$date": {"$numberLong": "<millis>"}}Where the values are as follows:
The 'time' portion of an ISO 8601 date is optional. So your first attempt will work, I just confirmed this.
Your json should looks like this: