Using Python, is there a way check if a date
field of a document in a MongoDB collection is in ISO format or in string format?
You can make use of fromisoformat
method in datetime
library.
from datetime import date
try:
date.fromisoformat(date_string)
except ValueError:
print("Invalid isoformat string")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With