$dateFromString
Reference group: Date expressions
What it does
Parses date text into BSON Date.
Syntax
{$dateFromString: { dateString, format?, timezone?, onError?, onNull? }}
Use case
Normalize imported dates.
$dateFromString: practical example
{ $set: { parsed: { $dateFromString: { dateString: "$dateText", format: "%Y-%m-%d", onError: null } } } }💡 Explanation
Parses date text into BSON Date.
When to use it
Normalize imported dates.
Key Takeaways
- Parses date text into BSON Date.
- Typical use: Normalize imported dates.