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

305
Views
How do i order by Date Firebase

I have some entries in a database and and they all contain a date string.

I have some TS like this

ref.LimitToFirst(10).orderByChild('date')

The problem i an having is that TS treats this as a regular string and just orders by the first number in the date. ex - 10/1/2021 would be ordered before 2/1/2021. How could i fix that ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can't fix this in code while depending on the database to perform the query. In Realtime Database, strings will always sort lexicographically - by their natural string order. You can't make it interpret the strings as something other than a normal string.

You will have to instead store an integer value that you can sort chronologically. In JavaScript, you can simply create a Date object and use its getTime() method field to get the Date's representation in millis since the unix epoch.

If you can't store a proper timestamp, then your only option is to read all the data and sort it yourself in your app, which will not scale well.

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!