Start Free Trial

Alteryx Designer Desktop Discussions

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

Date Format / current month minus 1 month

jgarcia0417
7 - Meteor

Hello,

 

I've tried just about everything on my workflow to filter this row of data.

 

Data input is a string written as "yyyy-mm"

 

I'm trying to convert it into a date so that I can filter for current month - 1 

Example return value should be "2022-06" since that it this month - 1 

 

tried datetime tool and converting the string to date format in select tool, not working too well for me.

 

 

Thanks!

7 REPLIES 7
BrandonB
Alteryx
Alteryx

Try DateTimeParse([DateColumn], "%y-%m") = DateTimeAdd(DateTimeToday(), -1, "months") in a filter where you swap out DateColumn with your date column

binu_acs
21 - Polaris

@jgarcia0417 One way of doing this

 

binuacs_0-1658168204617.png

 

jgarcia0417
7 - Meteor

Hi BrandonB, 

 

Thanks for the super fast response! 

 

This formula is great, but the date column im working on is in a string format :)

 

so values are returning as blank in filter tool

 

I attached a workflow example and select tool to simulate the field in my working input 

 

Thanks! 

BrandonB
Alteryx
Alteryx

The DateTimeParse function will turn that into a date so if you want an intermediate step you can use DateTimeParse([DateColumn], "%y-%m") and it should turn those strings into dates. I would recommend creating a new column rather than modifying the existing. 

BrandonB
Alteryx
Alteryx

Ah sorry quick adjustment, I wasn't accounting for the fact that today is the 18th and I needed to set it to the first of the month. Try this in your filter instead:

 

DateTimeParse([Funding Year], "%Y-%m") = DateTimeFormat(DateTimeAdd(DateTimeToday(), -1, "months"), "%Y-%m-01")

binu_acs
21 - Polaris

@jgarcia0417 updated your workflow

binuacs_1-1658168805132.png

 

jgarcia0417
7 - Meteor

Yes perfect!!!!

 

Thank you so much! 

Labels
Top Solution Authors