Skip to content
Advertisement

Use replace with interval in sql query

I want to show if 0 it will put a word, perm for example and if not 0 it will get the normal date using interval.

Tried to include it in replace.

REPLACE(REPLACE(usetime,0,'PERM'), add_time + interval usetime minute)

If usetime = 0

If usetime is not 0 and is something else(not a specific value)

Advertisement

Answer

Don’t use REPLACE(), use CASE:

You might want to use date_format() to format the date to a string with exactly the format you want.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement