Forum Discussion
m code for "mmm-yy"
Hello,
I am trying to create a custom column to convert a date to format "mmm-yy" using m code?
Hello jcastr02
you can use Date.ToText(Date,"MMM-yy"). Here an example where I added a new column to make the transformation you need
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUAyIjA6VYHTjHEMwxsoBxYgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}, "de-DE"), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Date.ToText(_[Date], "MMM-yy")) in #"Added Custom"Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
1 Reply
- Jimmy801
Community Champion
Hello jcastr02
you can use Date.ToText(Date,"MMM-yy"). Here an example where I added a new column to make the transformation you need
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUAyIjA6VYHTjHEMwxsoBxYgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}, "de-DE"), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Date.ToText(_[Date], "MMM-yy")) in #"Added Custom"Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy