Alteryx Designer Desktop Discussions

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

convert string to date (last day of the month)

LEXQ2005
8 - Asteroid

I want to convert V String to Date, and turn to the last day of each month. Such as convert Jun-20 to 6/30/2020. How to do that?

Current (Date Type: V_String)

Change to (Data Type: Date)

Jun-20

6/30/2020

Jul-20

7/31/2020

Aug-20

8/31/2020

Sep-20

9/30/2020

Oct-20

10/31/2020

Nov-20

11/30/2020

 

4 REPLIES 4
MarqueeCrew
20 - Arcturus
20 - Arcturus

Let's start with fixing the date to the first, then adding a month and finally subtracting a day. 

datetimeadd(

      Datetimeadd(

          DateTimeParse(

                left([current data],4) + "01-"+
                Right([current data],2), "%b-%m-%y")

      1,"Months")

-1,"days")


cheers,

 

 mark

 

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
LEXQ2005
8 - Asteroid

Thanks for replying. 

 

I pasted your formula to my workflow, but run into “Malformed Function Call”.

LEXQ2005_0-1593148604605.png

 

Now with the change of one joining data source, I need to convert the V_String to YYYY-MM-DD format. Will that be easier?

Current (Date Type: V_String)

Change to (Data Type: Date)

Jun-20

2020-06-30

Jul-20

2020-07-31

Aug-20

2020-08-31

Sep-20

2020-09-30

Oct-20

2020-10-31

Nov-20

2020-11-30

 

grazitti_sapna
17 - Castor

Hi @LEXQ2005  try using either I have two approaches to achieve the desired output.

 

grazitti_sapna_0-1593149329824.png

 

 

 

Sapna Gupta
RolandSchubert
16 - Nebula
16 - Nebula

Hi @LEXQ2005 ,

 

you could try:
DateTimeAdd(DateTimeAdd(DateTimeParse([Current], '%b-%y'), 1, 'month'), -1, 'day')

 

DateTimeParse([Current], '%b-%y') converts month-year to the first day of the month in date format, adding one month and subtracting one day results in the last day of the month.

 

Let me know if it works for you.

 

Best,

 

Roland

Labels