How to create a new column converting date to text

本秂侑毒 提交于 2021-02-11 15:07:44

问题


I need to create a new column with an IF.

If the difference between two dates is more than a month I have to use a text-like "much time" but if it is not I have to show a date.

So the date must be converted to a string to use a text column. How can I convert date to text?

Fecha_real =
IF( DATEDIFF(ventas[fecha_pedido]; ventas[fecha]; month) = 1 ;
    "much time";
    ConvertToTextInSomeWay  ventas[fecha]
)

回答1:


This is pretty simple with the FORMAT function.. For example, FORMAT(ventas[fecha], "Short Date") will convert fecha into textlike "12/31/2018".

That's just one format example. There are plenty of pre-defined and custom options if you'd rather something else. For example, FORMAT(ventas[fecha], "dd-mm-yyyy") would format that same date as "31-12-2018" instead.



来源:https://stackoverflow.com/questions/54045506/how-to-create-a-new-column-converting-date-to-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!