I have a table which I'd like to convert Null Date (my date format i.e 2014-02-12) to blank string but an error occurs whenever I do IsNull, I have mysql. Is there away to do it with isnull?
Asked
Active
Viewed 725 times
-2
-
Do you have a code sample, and what is the data type of the field? Also, are you talking about converting the *output* of a query, or the data in the field itself? – Andrew Barber May 13 '14 at 15:36
2 Answers
2
Try this:
SELECT ISNULL(CONVERT(VARCHAR, date_field), '')
FROM table_name

Isaac Kleinman
- 3,994
- 3
- 31
- 35
1
MySQL:
SELECT ISNULL(CAST(date_value AS char),'')
or
SELECT ISNULL(DATE_FORMAT(date_value , '%d %m %Y'),'')
SQL SERVER:
SELECT ISNULL(CAST(date_value AS VARCHAR(20)),'')

T McKeown
- 12,971
- 1
- 25
- 32
-
-
1I think Kermit realized that just seconds after posting the comment. heh – Andrew Barber May 13 '14 at 15:37
-
thanks guys, also, I have an issue because my date column is in temporary table? I tried ISNULL(CONVERT (VARCHAR(20), #a.date), ' ') but it can't pop up. Does it not apply for temp table? – user3597281 May 13 '14 at 15:40
-
try the other mysql ways first, shouldn't matter if it's in a temp table or not. – T McKeown May 13 '14 at 15:40