I want to save to db date as Date type so I got data like this in my db
2022-05-04T23:00:00.000+00:00
i want to save just
2022-05-04
Unfortunately, MongoDB Date data type always has the time part. It is not like many SQL databases which offer e.g. Date and DateTime data types.
A common workaround is to store the date instead as a number data type, with format "YYYYMMDD".
With this, we can still easily query with comparison operators.
It is not uncommon that people also do this trick for SQL databases, even when a Date-only data type could have been used.