Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Get Previous Month first day at any given date

msedrech0114
7 - Meteor

Can anyone help I want to add a formula expression that would get the first day and last day of previous month of a given date field.

 

e.g

Field_1: 2018-05-05

Output_1: 2018-04-01

Output_2: 2018-04-30

 

In sql, there's an expression to handle this case but can't find a solution yet in Alteryx.

 

 

Appreciate any help in advance. 

 

 

Mark

3 REPLIES 3
AdamR_AYX
Alteryx Alumni (Retired)

I think these formulas do what you want:

 

Previous Month = DateTimeAdd([OriginalDate],-1,"month")

FirstOfPreviousMonth = DateTimeAdd([Previous Month], 1-DateTimeDay([Previous Month]), "days")

LastOfPreviousMonth = DateTimeAdd([OriginalDate], 0-DateTimeDay([OriginalDate]), "days")

 

 

Adam Riley
https://www.linkedin.com/in/adriley/
msedrech0114
7 - Meteor

Thank you AdamR! your formulars work!

sushobhan
5 - Atom

Try this

DateTimeAdd(DateTimeLastOfMonth(),-2,"months")

Labels
Top Solution Authors