CODA Pro Challenge Insert rows based on date range and selected days of the week

Hi,

I am trying to see if this is possible. I have played around with the scenario, but can’t wrap my head around it. Thanks for any help or suggestions. :smiley:

@Nick_J

Here some ideas you can explore for the first parts of your logic. I think there may be some context issues with CurrentValue. The days of the week logic will probably use Switch statements, but I ran out of time before I could play with that.

1 Like

Here you go:

(Note that docs seem to be incorrect — Weekday() returns 1 for Sunday, not Monday. Also disregard the fact that I’m juggling dates and integers — internally they seem to be the same thing)

3 Likes

@Paul_Danyliuk

:point_down: Good stuff. Bookmarked.


SwitchIf(
Everyday, Sequence(1, 7),
[Monday thru Friday], Sequence(2, 6),


Sequence(1, [Filtered days].Count() * [Number of enteries per day]).FormulaMap(
[Filtered days].Nth(RoundUp(CurrentValue / [Number of enteries per day]))
))

3 Likes

Dear @Paul_Danyliuk,

I know that you have a serious skill set and again you are supprising me with the simplicity on how you approach the challenge. Much respect for that. :crown:

Just one question: The days are displayed as a number, is this a kind of ID for each day?

Thanks for your input :handshake:

1 Like

WOW! Great job everyone. Very impressive :smile: Now I need to reverse engineer everything to learn why it works. Thank you very much!

1 Like

I assumed it was number of days since some date — e.g. in some of my apps I used to store dates as number of days since Jan 1, 1970.

I just checked, and in Coda any date/datetime value seems to be the 1-based index of the day (possibly with fractions) since Jan 1, 1900 midnight UTC (i.e., Jan 1, 1900 corresponds to value 1)

One thing to note though that displayed dates take doc time into account. I.e., the doc’s timezone is UTC-7, hence the value 1 in renders as Dec 31, 1899 (because in Pacific time zone it’s not midnight yet).

Anyway, the bottom line is that sequential days will correspond to sequential integers.

And thanks for the compliments. You’re too kind as always :slight_smile:

3 Likes

This is because there is some part of the World with weeks starting from Sunday, and Coda developers are from there! :slight_smile: See Localization

No, I totally get it that Sunday is 1 — I mean the docs were (and still are at the moment of writing) incorrect: https://coda.io/formulas#Weekday I reported it yesterday, but the docs haven’t been updated yet — they still say Monday = 1.

1 Like