Create records for a range of dates with JavaScript

I was wondering if anybody can help me write JS code that would automatically create date records within a specified range.

For example, I want to list all days from August 2023, by creating 31 records starting from 2023-08-01 and ending with 2023-08-31 in the ‘Date’ field.

Similarly, I would use this code to create 365 records if I wanted to have a separate date record for each day within a year (or 366 for a leap year).
How can I achieve this?

Hi @dimitri.

You can use this script to insert multiple rows. To specify the start and end two input boxes will pop up when you start the script. The scripts stopped working on my pc after some runs. I didn’t analyze the cause but I would say the reason is javascript is not the right tool to create massive data in SeaTable. You should think about running a python script or an external api call.

The two dates have to be in the format: MM/DD/YYYY

const startDate = new Date(prompt("Enter start date"));
const endDate = new Date(prompt("Enter end date"));
const table = base.getActiveTable();

let loop = new Date(startDate);
while (loop < endDate) {
  let newDate = loop.setDate(loop.getDate());
  loop = new Date(newDate);
  base.addRow(table, { 'Date': base.utils.formatDate(loop) });

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.