Alteryx Designer Desktop Discussions

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

Date Conversions

tlewis
7 - Meteor

I am trying to create a date to be used in a formula calculation. The date will be a concatenation of information extracted from another date field and a hard coded year.

How would I concatenate the information below into a date that could be used in the bottom formula?

Concatenate Date

Month = DateTimeMonth([DisDate])

Day = DateTimeDay([DisDate])

Year = 2013

 

If [TermDate] < "Concatenated Date" Then "Yes" Else "No" Endif

 

3 REPLIES 3
Thableaus
17 - Castor
17 - Castor

Hi @tlewis 

 

If all of your fields are Strings, it's pretty simple:

 

Year + "-" +  PadLeft(Month, 2, "0") + "-" + PadLeft(Day, 2, "0")

 

PadLeft function is to add a 0 to Months and Days < 10.

 

Cheers

tlewis
7 - Meteor

The fields where not all text. The DOD field is a date format. I think I was able to use your suggestion along with a ToString function to achieve the desired result. Is this acceptable or is there a more straightforward method?

"2013" + "-" +  PadLeft(ToString(DateTimeMonth([DOD]),0), 2, "0") + "-" + PadLeft(ToString(DateTimeDay([DOD]),0), 2, "0")

Thableaus
17 - Castor
17 - Castor

@tlewis 

 

Close enough, I'd just get rid of the 0's in the ToString function.

 

"2013" + "-" +  PadLeft(ToString(DateTimeMonth([DOD])), 2, "0") + "-" + PadLeft(ToString(DateTimeDay([DOD])), 2, "0")

 

Another way would be using replace function.

 

Replace([DOD], ToString(DateTimeYear([DOD])), "2013").

 

This would work as well.


Cheers,

Labels