In the Compass's Documents tab, ADD DATA -> Insert Document. You will find a dialog as shown in the picture.
Select the VIEW "Field-by-Field Editor" mode (the other one is the JSON mode). To create a new date field - enter example field name "dob"
, then select field type as Date
, and enter date value (for example 2021-07-15T11:30:45
). This will be saved as a date field in your collection's document. See Compass - Insert Document.
If you use the "JSON" VIEW, then create the date field with this syntax:
{
"dob": { "$date": "2021-07-15T10:30:48.021Z" }
}
The newly inserted document will look like in the below picture. And, you can verify the field type is Date
in the Analyze Your Data Schema tab.