Populate table with data range

Hi,

I have 2 datapickers (only date) start and end.

How can I popupate a table with all date range from start to end

excuse me for my english.

Hey renatoR! Welcome to the community :-).

Can you please reword your question? I'm not sure I get what you're trying to achieve.

when the client clicks on the run button, I want the table to be updated with all the dates from start to end

Using this code Stackoverflow, something like this should work;

let fromDate = moment(dateSelectorFrom.value)
let toDate = moment(dateSelectorTo.value)
let diff = toDate.diff(fromDate, 'days')
let range = []
for (let i = 0; i < diff; i++) {
  range.push(moment(fromDate).add(i, 'days').format('YYYY-MM-DD'))
}
return range

Thank you @jonathanbredo ,

sorry, but why the table does not populate?

Hi @renatoR,

It looks like the table is set up properly :thinking: Can you try running the JS query again? How is the JS query triggered in the app?

In this moment I run the query manually

If you wrap it into the column like this, a table populates;

let fromDate = moment(dateSelectorFrom.value)
let toDate = moment(dateSelectorTo.value)
let diff = toDate.diff(fromDate, 'days')
let range = []
for (let i = 0; i < diff; i++) {
  range.push(moment(fromDate).add(i, 'days').format('YYYY-MM-DD'))
}
return {date: range}

I recommend that you play around with Retool's table component and how it works with columns, as this will help you build really cool experiences in Retool :-).

2 Likes

Ah, right! Thanks @jonathanbredo :slightly_smiling_face: