I have a query that among other fields returns a due date and cutoff date. sometimes these field would be null and so, when converted like so:
FROM_UNIXTIME(assignment.cutoffdate, '%d-%m-%Y %H:%i')
will display 01-01-1970 02:00
.
How can I display an empty string or some text like 'not available'
in such cases? please note that using a "where date is not null"
condition will not do because a need all results, including those with null in date fields.
答案 0 :(得分:0)
只需使用IF
语句:
IF(assignment.cutoffdate IS NULL, 'not available', FROM_UNIXTIME(assignment.cutoffdate, '%d-%m-%Y %H:%i'))