Adding Days() duration to a date not working

Hi there @mallika

I ran into this issue which as far as I can tell has to be a bug because it worked perfectly before and when I test the same thing in another doc it works as expected so I’m not sure what I can do to fix it.

I’m simply adding days with the Days() function to a date to add a number of dates to a list in sequence. But for some reason instead of adding a day to the date it just adds the number of days to the end as text like this:

The code I have is the following:

ToDateTime(Concatenate([Select Project].Start.ToText(), " ", Time(10, 00, 00))) + Days(1)

On top of this if I just take away the addition of the Days() duration it just says that the action was unable to run which makes no sense because it runs fine with it…

Let me know if you need more info, I didn’t want to overwhelm.
Was there some sort of update to these functions that could’ve introduced this bug? I can’t seem to reproduce the problem in another doc but as I said I haven’t changed the code and it worked fine before.

Many thanks in advance,
Daniel

Hey @Daniel_Meszoly ,

your formula looks a little unsafe when it comes to data types, this one should always run:

ToDateTime(Concatenate(ToText([Select Project].Start + 1), " ", Time(10, 00, 00)))

Assuming “Start” is a date type

Best regards
Marius

Thanks for the help that works perfectly!

I’m still curios though why it wouldn’t work the old way especially if it worked fine before. What do you mean by unsafe? It shouldn’t matter if I add a duration to a time or a time&date should it?

Hey @Daniel_Meszoly ,

it’s unsafe, because even though there is the Concatenate() function, you can still create a new string by adding strings together with “+”. With your formula, coda has to decide which type it should cast your value to, but even if you determined the type in your column as date/time, the casting algorithm can sometimes make the wrong choice. Thats why it evaluated your formula as a string and then complained about the wrong type in your column (triangle in the upper right corner).

Best regards,

Marius

1 Like

Thanks for explaining that makes sense!

Although since the ToDateTime() function should return a datetime type to which I add a duration type if Coda decides to add them together as a text that’s probably a bug especially since this didn’t happen before. I guess this is where I can report bugs so hopefully they are reading this to fix the problem.

1 Like