Help with Invoice number formula

I have this formula on my invoice Database in Coda that automatically creates the invoice number. My format is this one: 207/07/2025 . So the first 3 numbers are increased, and then the month and the year.

In Coda, I have this formula:

Concatenate((([Invoices DB].[Invoice Number].Last().slice(1,3)) +1 ),“/”, Today().Month().LeftPad(2,0),“/”, Today().Year())

But because I cannot transform text to numbers, like in Coda, I don’t manage to achieve this.

Any ideas how to do this?

Thanks,

Eva

Why do you need to convert text to numbers?

Can’t you just use something like this:

Middle([Invoice Number],1,3) + “/” + ToText(Month(Today())) + “/” + ToText(Year(Today()))

?

But be aware, in Fibery Today() is not a static value - it will change every day, causing your formula to update.

Perhaps you want to use a date field (Creation Date?) instead

The invoice number is not a number field is a text field, so how can I increase automatically, and add one more when a new row is created?

“Date created” field is a good idea, thanks!

I get this error…

Well, you have a couple of options: you can either utilise the Public Id field (which is unique and increments each time an entity is created) or you can make an automation rule to write a number field each time an entity is created, and then use ToText on that number when necessary.

Note: due to the way Public Id works, it is not guaranteed to be exactly one higher than the current highest value. See here

1 Like

I think there is a problem with how discourse renders double quotes in posts.

Try typing them, instead of copy pasting

or use single quotes:

Middle([Invoice Number],1,3) + '/' + ToText(Month(Today())) + '/' + ToText(Year(Today()))

Yes, you’re right. Thanks!
Now I have to figure out how to get the last invoice number. Does the formula Last () work?

If you have a collection field, you can use something like:

Invoices.Max(Number)

but Fibery doesn’t allow formula fields to query an entire database.

Thank you, Chris! I did not know about these differences in the formula field and rows! :slight_smile: Yes, I managed with a Rule that increases a number in a Field(Column), and then the name formulas do the rest, adding the “creation Date” field, month, and year!
Max () worked in the Rule formula!