Date format mm/dd/yy in formula?

Hi…
I figured out that +thisRow.[Enter date].format("{1:00}/{2:00}", Day(thisRow.[Enter date]), Month(thisRow.[Enter date])) would give me 05/20 but if I try to add year I get an unexpected result:

+thisRow.[Enter date].format("{1:00}/{2:00}/{3:00}", Day(thisRow.[Enter date]), Month(thisRow.[Enter date], Year(thisRow.[Enter date])) gives me 05/20/05.

I cannot figure out why year comes out as “05”…can anyone help?

My goal is “05/20/22”…

Many thanks!

Gregg

Hi @Gregg_Stebben , not sure what the problem is, but I just put together a sample that might be what you’re looking for:

2 Likes

Thank you…this is perfect!

Just wondering if there is a way to alter your formula to get just the last two digits of the year (22)?

I am always trying to learn…so it’s interesting to me that two different formulas give similar results.

Your formula with field.Day() etc gave very similar results to my formula with field.format("{1:00}/{2:00}/{3:00},(Day(field), Month(field), etc

Your formula is very tidy, mine was messy. But why did both give the same result for Day and Month but my formula didn’t give the right result for Year?

Thank you again!

That’s because most (all ?) formulas can be written as chained formulas.
Here is an article about it: Writing in Coda's formula language | Coda Help Center

For the last 2 digits, you can use this function: Coda | Formula library

I’ve updated my examples to show you how to do it with chained functions.

Glad to help, I’ve always found help around here, I try to pay it back some when I have the time :slight_smile:

thx @Martin_Portevin for using right, I thought about Slice(-2) and did not realize that Right() would be an option as well. Cheers, Christiaan

1 Like