Rod
Rod

Reputation: 1

How to create a new column converting date to text

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]
)

Upvotes: 0

Views: 12782

Answers (1)

Alexis Olson
Alexis Olson

Reputation: 40204

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.

Upvotes: 1

Related Questions