Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

85
Views
How to get only yyyy-mm-dd and ignore all the rest

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
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!