Get Previous Month first day at any given date
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
Solved! Go to Solution.
- Labels:
- Tips and Tricks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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")
https://www.linkedin.com/in/adriley/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you AdamR! your formulars work!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Try this
DateTimeAdd(DateTimeLastOfMonth(),-2,"months")
