Forum Discussion
Anonymous
8 years agoNot applicable
Previous Month from a Date Column in Query Editor
So I have to do this in Query Editor. I have a date column that has various dates like 2/1/16, 3/3/16, 4/2/16, etc.. I need to create a column with a date that is the last day of the previous month based on this date column. So the result from the previous dates would be 1/31/16, 2/29/16, 3/31/16, etc.
Not very familiar with M Code so I'm unsure how to do this. I can't just subtract one day since the date column could be the second or third day or so into the next month.
- Anonymous8 years ago
Anonymous,
You can add a custom column and paste in the following code:
=Date.EndOfMonth(Date.AddMonths(DateColumn, -1))
3 Replies
- AnonymousNot applicable
Anonymous,
You can add a custom column and paste in the following code:
=Date.EndOfMonth(Date.AddMonths(DateColumn, -1))
- AnonymousNot applicable
Anonymous Easy enough! Thanks for the help!
- TorsteinZahlFrequent Visitor
Easy and nice, no techincal debt