473,414 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

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 7044
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

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

Similar topics

7
by: Niall Porter | last post by:
Hi all, I'm building an ASP app on a Windows 2000/IIS machine which interfaces with our SQL Server 2000 database via OLE DB. Since we're based in the UK I want the users to be able to type in...
6
by: Martin | last post by:
Dear Group Just wondered how I can avoid the CHAR(32) to be inserted if @String1 is NULL? SET @String3 = ISNULL(@String1,'') + CHAR(32) + ISNULL(@String2,'') Thanks very much for your...
2
by: ggnanaraj | last post by:
In AS/400, have a table that has a character field defined. This has to be converted to date format of YYYY-MM-DD. The sample character data is as follows: 02/05/2005. In UDB, you can do a...
5
by: Donkey | last post by:
Hello, I want to find out how many digits does each date type have and how many bytes does it occupy in memory, so I wrote a program below: #include <stdio.h> const long double...
16
by: madeleine | last post by:
Please can someone help me, I think I may go mad with this one: Do While Not IsNull(CDate(FormatDateTime(rst!F1.Value, vbShortDate))) If IsNull(CDate(FormatDateTime(rst!F1.Value, vbShortDate)))...
2
by: syntego | last post by:
We commonly use triggers to log changes to our main tables to historical log tables. In the trigger, we create a concatenated string of the old values by casting them as follows: ...
0
by: coolvivek33 | last post by:
hi i am facing a strange problem i am trying to build report using sql server 2005 and microsoft visual studio2005 now it is in requirement that i should seperate date from time.I have done that...
2
by: Chris H | last post by:
Hi, I'm trying to concatenate a Description (nchar(100)) and Date (datetime) as Description and my initial effort was just "...description+' '+open_date as description..." which throws a date/...
2
by: SHASHANKSHARMA | last post by:
Dear All, I am facing a problem after migration DB from SQL to ORACLE. There is a function ISNULL() supported by SQL but in ORACLE it is NVL(). But is there any way to use ISNULL in ORACLE...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.