Sample Header Ad - 728x90

How to convert a datefield from string to date?

1 vote
1 answer
250 views
Here is the query that I am using. What I need to extract is the data for the last 10 minutes. But no records found is the output for this query, I think this is due to the type of data that were inserted to created_at field, it should be date field but string were inserted. How to convert this field so I can use it on the **$match** db.collectionName.aggregate([{ $match : { created_at : { $gte : new Date(ISODate().getTime() - 1000 * 60 * 10) } } }]);
Asked by Driggs Alonzo (31 rep)
Sep 13, 2019, 02:23 AM
Last activity: May 25, 2025, 04:04 AM