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

General Discussions

Discuss any topics that are not product-specific here.
SOLVED

Convert month to number without leading zero

mestra28
6 - Meteoroid

Hello,

 

I currently wanted to construct a workflow that pulls in the last month as a number without a leading zero.

I came up with this:

(DateTimeFormat(DateTimeAdd(DateTimeFirstOfMonth(),-1,"months"),"%m")

However I want to get rid of the leading zero.

 

3 REPLIES 3
binuacs
21 - Polaris

@mestra28  the TrimLeft function will be useful in this use case

 

binuacs_0-1649887453571.png

 

 

 

 

 

TrimLeft( DateTimeFormat(DateTimeAdd(DateTimeFirstOfMonth(),-1,"months"),"%m"),'0')

 

 

Qiu
21 - Polaris
21 - Polaris

@mestra28 
you mentioned that you want a number, so use ToNumber function to convert the string to number will natually remove the leading zero.

0414-mestra28.PNG

mestra28
6 - Meteoroid

@binuacsThis worked, thank you!

 

Labels