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

192
Views
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
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!