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

193
Vistas
GlobalFilter on Date in REACT-Table

I want to filter the Date, but my problem is that I have to give the Date unformatted to the React-Table because of the sort-Function. So I define my Column like this:

 {
    Header: "ORDER_DATE",
    accessor: "creationDate",
    sortable: true,
    Cell: ({value})=>{return format(new Date(value),'dd.MM.yyyy')}
 }

I give the Date in this format to the Column: "2021-09-20T00:00:00+0000". Adding the format Function to the Cell-Property, means that I write the unformatted Date to the Table but it will be displayed formatted. Now I have my globalFilter where I can filter with an InputField. The formatted Date has this format: dd.MM.yyyy and unformatted it is like this: yyyy-mm-dd. My idea was to split and convert it. Here my code

const formatWhenDate = (value) => {
        return value.split(".").reverse().join("-");
 }

<input
        id="test"
        onChange={(e) =>{ setInput(e.target.value);setFilter(formatWhenDate(e.target.value));}}
 />

It also works, but only when I enter the full month and Year because I can´t change for example: 17.0 to 0X-17 (X is a placeholder for a empty value).

Does know somebody how to handle it in relation to the React-Table or does somone could edit my function(formatWhenDate) so that also dates with not full month(11.0 intead of 11.09) or years(20 instead of2021 will be filtered correctly?

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