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

327
Views
How to use query from firestore using timestamp

I am using a date range picker where I will let my user set the date range of the data that they will query from firestore. I already can get the value of the date range picker and store it from a variable. My problem is I don't know how to query on firestore referencing timestamps.

this is my function for querying documents from a firestore collection. So far I can only collect all data but can't collect filtered data (by timestamps).

export async function Getfs(){
console.log("Get firestore run >>");
var f = document.getElementById("firstDate").value; // starting date
var s = document.getElementById("secondDate").value; // ending date
const fs_snap = await getDocs(query(collection(fs, "sens02"),orderBy('ts')));
}

This is what my firestore document looks like

and this is how I designed my date range picker using html input date date range picker

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

0

You need to use the methods of the Timestamp class.

More precisely, in your case, you need to use the fromDate() as shown in the below example:

const q = query(
  collection(fs, "sens02"),
  where('ts', '>=', Timestamp.fromDate(new Date('2022-05-28'))) // For example we use the 28/05/2002
);

const querySnapshot = await getDocs(q);

querySnapshot.forEach((doc) => {
  console.log(doc.data().ts.toDate());
});
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!