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.
1 7044
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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)))...
|
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:
...
|
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...
|
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/...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
| |