Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

258
Vistas
How can I filter documentdb records based on timestamp?

I am using documentdb database since long,

thus it has lots of records/documents in collections,

No to simplify it I want to fetch records/documents based on timestamp.

  1. I want to fetch all records which are created in last 1 day.
  2. I want to fetch all records which are created in last 15 days.
  3. I want to fetch all records which are created in last 1 month.
  4. I want to fetch all records which are created in last 1 year.

I have tried to rite query like this but its not working.

var curDate = new Date().getTime();
SELECT * FROM r WHERE r._ts >= @curDate AND r.studentId=@studentId
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

new Date().getTime() docs say

A number representing the milliseconds elapsed between 1 January 1970 00:00:00 UTC and the given date.

_ts docs say

a number representing the number of elapsed seconds since January 1, 1970

So you are comparing milliseconds to seconds, which won't yield any results.

You need to divide the first value by 1000 before you compare it to the second value. And, of course, you need to subtract 1 day, 1 month or whatever value you need, e.g.

var twoDaysAgo = new Date();
twoDaysAgo.setDate(d.getDate() - 2);
var threshold = twoDaysAgo.getTime() / 1000;

SELECT * FROM r WHERE r._ts >= @threshold AND r.studentId=@studentId
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda