SmallDateTime and NULL Values

  • Thread starter Thread starter Fred Nelson
  • Start date Start date
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
 
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
 
Back
Top