SmallDateTime and NULL Values

F

Fred Nelson

Hi:

I'm a relative Newby writing my first vb.net web application that uses SQL
SmallDateTime fields.

I have some records that contain null values in the datetime fields and they
return #12:00:00 AM# rather than blanks as I would like them to - even if I
set them = nothing.

Is there a simple way to stop this in the class library or in the stored
procedures? Is there a quick check for an empty date other than coding if
var = "#12:00:00 AM# all the time?

Any suggestions would be greatly appreciated!

Thanks,

Fred
 
N

Natty Gur

Hi,

You can use CONVERT to convert datetime to varchar and then ISNULL to
replace NULL with ''. You won't get date time but not the default
datetime value either.

select innull(convert(VARCHAR,startDate),'') as Exp1 FROM MyTable.

HTH
Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top