ugotchi
ugotchi

Reputation: 1013

Can MongoDB aggregation pipeline $gte and $lte work on dates in string format "Y-m-d H:i:s"?

I know from implementation that the method $gte and $lte work correctly with just dates specified as strings in the format "Y-m-d", what I would like to know if it's possible for the methods to work if I specify the time aswell like thus:

"Y-m-d H:i:s"

Anyone know if this is possible or not?

Upvotes: 0

Views: 186

Answers (1)

libik
libik

Reputation: 23029

If H:i:s is always two-digit, i.e. 14:05:15 then it will be ordered correctly.

If it can contain one-digit in any part, i.e. 14:5:15, then it will not be ordered correctly.

Upvotes: 1

Related Questions