ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

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
binu_acs
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
Top Solution Authors