Forum Discussion
previous date
Hi ,
Im using this for current month and year which is working fine.
currentdate=(Date.ToText(DateTime.Date(DateTime.LocalNow()),"MMyyyy"))
Output is =112022
now i want to get prevoius month
Pdate=(Date.ToText(DateTime.Date(DateTime.LocalNow()),"MMyyyy")) -1
but its not working please advise.
Hi faheem_Latif_BI ,
Please try below mquery code in custom column:-
Text.PadStart(Text.From(Date.Month(DateTime.LocalNow())-1),2,"0")&Text.From(Date.Year(DateTime.LocalNow()))
7 Replies
- Samarth_18Community Champion
Hi faheem_Latif_BI ,
Please try below mquery code in custom column:-
Text.PadStart(Text.From(Date.Month(DateTime.LocalNow())-1),2,"0")&Text.From(Date.Year(DateTime.LocalNow())) - faheem_Latif_BIHelper I
Thanks for reply im using like this but giving me error
Table.AddColumn(#"Added Custom", "Previous_MonthYear", each Date.ToText(Text.PadStart(Text.From(Date.Month(DateTime.LocalNow())-1),2,"0")&Text.From(Date.Year(DateTime.LocalNow())),"MMyyyy"))
- Samarth_18Community Champion
Could you please share the error?
- faheem_Latif_BIHelper I
- wdx223_DanielCommunity Champion
Pdate=Date.ToText(Date.AddMonths(DateTime.Date(DateTime.LocalNow()),-1),"MMyyyy"))