내 커뮤니티 업적 표시줄을 확대합니다.

Don’t miss the Workfront AMA: System Smarts & Strategic Starts! Ask your questions about keeping Workfront running smoothly, planning enhancements, reporting, or adoption, and get practical insights from Adobe experts.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Getting the last 2 characters of the entry date

Avatar

Community Advisor

I've created a field to concatenate 5 fields to create an auto-populated job number. I need Agency Code, Client Code, Product Code, Year (2 characters only), and Job ID (a unique hand-typed string in another field). So far I have

CONCAT(Agency Code,Company.Client Code,Company.Product Code) and that works fine.

I need to add the last 2 characters of the entryDate year next, like 2020="20", 2019="19", etc.

I can't use the expression "RIGHT({entryDate},2)" because RIGHT seems to only work on a string, not a date. There has to be an easy way to achieve this, right?

I thought maybe I have to coerce a date to a string and then grab the right 2 characters but I have no idea where to start with coercion. Is that even a thing in text mode?

Help!

Thanks

주제

토픽은 커뮤니티 콘텐츠를 분류하여 관련성 있는 콘텐츠를 찾는 데 도움이 됩니다.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

I am not sure why anyone would choose "date" for the format (in my mind, that would turn everything into a date).

The RIGHT(STRING(Entry Date),2) calc works fine as either a number or a text field (I would tend towards text but that's just because I don't want people adding or av-ing the numbers that come out as a result).

PS: I just realized I should add that the calc gave me 20 as a result, which might be the first or last two digits of this year; who knows. 🙂

원본 게시물의 솔루션 보기

10 답변 개

Avatar

Level 10

Hi Randy, what if you RIGHT the STRING format of the date as follows?

RIGHT(STRING({entryDate},2))

I don't know that it will work, but seems logical.

Thanks,

Narayan

Avatar

Community Advisor

Hi Randy,

Similar but slightly different from Narayan's, I'd suggest RIGHT(YEAR({entryDate}),2).

For details on YEAR and all the other juicy bits, I also invite you to bookmark this page, or (if you prefer a pattern), search for CONCAT in 0ne, which seems to bring it back among the top 5 results.

Regards,

Doug

Avatar

Community Advisor

Hi Doug,

That should work, but doesn't. Shouldn't that parens after the entryDate} be moved to the end? so it's "RIGHT(YEAR({entryDate},2))"? Either way I still get Invalid Expression.

TY

Curious Randy,

YEAR({entryDate}) takes the year portion of the entryDate (e.g. "2020"), and RIGHT(...,2) then takes the rightmost two characters of that result (e.g. "20"). Since entryDate is always a required field, I'd expect that if you set your formula (temporarily) to simply RIGHT(YEAR({entryDate}),2) that you will see results.

Once you do, you can then use CONCAT to (gradually) add each portion, confirming as you do so that you continue to see results, which (just a guess) might look something like this:

CONCAT({DE:Agency Code},{company}.{DE:Client Code},{company}.{DE:Product Code},RIGHT(YEAR({entryDate}),2),{DE:Job ID sequential number suffix})

Regards,

Doug

Avatar

Community Advisor

How frustrating! That no worky either. It doesn't even matter if I choose text or date for the format.

OK, This is a bit confusing. This sorta works: RIGHT(YEAR(Entry Date),2) but the result is "1/1/70", bizarre!

0690z000008OBekAAG.png

Avatar

정확한 답변 작성자:
Community Advisor

I am not sure why anyone would choose "date" for the format (in my mind, that would turn everything into a date).

The RIGHT(STRING(Entry Date),2) calc works fine as either a number or a text field (I would tend towards text but that's just because I don't want people adding or av-ing the numbers that come out as a result).

PS: I just realized I should add that the calc gave me 20 as a result, which might be the first or last two digits of this year; who knows. 🙂

Avatar

Community Advisor

That works! I changed the format to text. It wasn't working with my earlier tries and just never changed it back.

I tested with a project opened in 2019, it works.

Thanks

Avatar

Level 10

Great news! For those following this thread, I've added a "Calculated Data Expressions" link to the WFPro Training page for quick access among other tools. --Narayan

Avatar

Community Advisor

Thanks Narayan, That's a good reference. The one good thing I learned here is that you can coerce a date to a string by using STRING. I imagine you can also coerce a string to a number.

Avatar

Community Advisor

Thanks Narayan,

I just tried this

CONCAT(Agency Code,Company.Client Code,Company.Product Code,RIGHT(STRING({entryDate},2),Job ID sequential number suffix)

but got the dreaded "Custom Expression Invalid. This is an invalid custom expression, please try again.".

it won't even let me save it 😐

If I use "CONCAT(Agency Code,Company.Client Code,Company.Product Code,Job ID sequential number suffix)" it works great, I just need that 2 character year to complete it.

Even if I create a new field called "year concat" and try "RIGHT(STRING({entryDate},2))" it's an invalid expression.