- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Jul 05, 2023 08:24 PM
Hi Airtable community,
I'm trying to write a script to update a column on my table based on different types of date ranges. I have the following columns that are relevant to the script:
First column defines the type of date. Type 1 is regular date range (from day A to day B), type 2 is range with days of the week (Mondays and Saturdays from day A to day B), type 3 is random dates (July 1st, 7th, and 19th).
Second and third columns are start and end dates, which are mandatory for every row.
Fourth column is only filled out for type 3 dates, and it has DD/MM/YYYY dates separated by spaces.
Fifth column is only filled out for type 2 dates (range with days of the week), and includes the days of the week to be included, separated by spaces.
I created the script below to populates another column with a string of DD/MM/YYYY dates in each of those scenarios. However, the rows with date ranges with days of the week are not populating at all, and I don't know how to fix it. It looks like it may be because the parameters in the getDatesInRange function are not in the right format.
Any ideas?
Thank you!
![Sho Sho](https://community.airtable.com/legacyfs/online/avatars/3X/9/4/944df447ee3248d602da7f514c009b40d45b1a92.jpeg)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Jul 05, 2023 08:50 PM - edited ‎Jul 05, 2023 08:53 PM
Hi @LKI ,
I just had a quick look
This line is wrong.
const dayOfWeekAbbreviation = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][dayOfWeek];
If possible, an error should be output, so share it.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Jul 05, 2023 10:02 PM
Hi Sho,
It doesn't actually hit an error, it just doesn't generate dates when it should (see empty array in the console log). I think it's because that specific start date is still "2023-07-01" while the other ones were formatted?
![Sho Sho](https://community.airtable.com/legacyfs/online/avatars/3X/9/4/944df447ee3248d602da7f514c009b40d45b1a92.jpeg)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Jul 05, 2023 11:18 PM
My mistake. It was an unfamiliar way of writing for me
Debugging other people's code is hard...
I guess it would be easier if I could test it on Airtable
![](/skins/images/75AB00B4920FD2D67A8CABF77C9DECC4/responsive_peak/images/icon_anonymous_message.png)