Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Replace only the year in Date Column using a condition

Mahesh6279
7 - Meteor

Please help with an easy way to replace only the year of the date based on condition

* if the year in the date is greater than 2032 then change it to 2032

 

it should look like this.

 

Mahesh6279_0-1687157272595.png

 

 

Appreciate your help. Thanks

6 REPLIES 6
binuacs
21 - Polaris

@Mahesh6279 One way of doing this

 

binuacs_0-1687158028136.png

 

 

Hamder83
11 - Bolide

Hamder83_2-1687158504339.png

Hamder83_3-1687158510374.png

 

 

ShankerV
17 - Castor

Hi @Mahesh6279 

 

One way of doing this.

 

ShankerV_0-1687158497998.png

Many thanks

Shanker V

ShankerV
17 - Castor

Hi @Mahesh6279 

 

ShankerV_0-1687158562941.png

 

IF tonumber(right([Field1],2))>32
THEN REGEX_Replace([Field1], "(\d{1,2}/\d{1,2}/\d{2})(\d{2})", "$1")+"32"
ELSE [Field1]
ENDIF

 

Many thanks

Shanker V

 

Mahesh6279
7 - Meteor

can you please modify the code for this date format " 2037-12-31"

 

 

Mahesh6279_0-1687164481104.png

 

Hamder83
11 - Bolide

IF
ToNumber(left([PRICING_VALID_END_DT], 4)) > 2032
THEN
"2032"+substring([PRICING_VALID_END_DT],4,10)

ELSE
[PRICING_VALID_END_DT]
ENDIF

Labels