468,765 Members | 1,036 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

ISNULL for a date to char conversion

I am trying to return either a date in MMDDYYYY format, or a blank fixed width of 8 as part of a giant concatenation. For some reason, I am stuck on this point:

ISNULL(REPLACE(convert(char(8),mydate,101),'/',''),CONVERT(char(8),''))

"mydate" is a field of type datetime, but can sometimes be null.

The problem I am running into is that whether I write this as an "ISNULL" or a CASE statement, it doesn't seem to be able to return a char(8) blank when null.

I checked, and REPLACE(convert(char(8),mydate,101),'/','') does return a null..

Thoughts?

Thanks in advance.
Nov 19 '07 #1
1 6791
deepuv04
227 Expert 100+
I am trying to return either a date in MMDDYYYY format, or a blank fixed width of 8 as part of a giant concatenation. For some reason, I am stuck on this point:

ISNULL(REPLACE(convert(char(8),mydate,101),'/',''),CONVERT(char(8),''))

"mydate" is a field of type datetime, but can sometimes be null.

The problem I am running into is that whether I write this as an "ISNULL" or a CASE statement, it doesn't seem to be able to return a char(8) blank when null.

I checked, and REPLACE(convert(char(8),mydate,101),'/','') does return a null..

Thoughts?

Thanks in advance.
Use the following

select ISNULL(REPLACE(convert(char(10),enddate,101),'/',''),CONVERT(char(8),'')) FROM assessments
Nov 20 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by ggnanaraj | last post: by
5 posts views Thread by Donkey | last post: by
16 posts views Thread by madeleine | last post: by
2 posts views Thread by SHASHANKSHARMA | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.