Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 DateTime and Decimal TO VARCHAR

Author  Topic 

twinklestar0802
Starting Member

17 Posts

Posted - 2005-05-31 : 09:19:06
Guys, i need ur help again... i want to display all data. The columns CheckDate (datetime) and CheckAmount (decimal) can be null.
In my query, i replace them with the ''. If checkdate is null, it appears to be 1/1/1900. and checkamount will generate and error.
I want checkdate and checkamount to appear blank if they are null. How????? Thanx guys

SELECT OR_no, InvoiceNumber,
PaymentType, AmountPaid, isnull(CheckNumber,''),
isnull(CheckDate,''), isnull(CheckAmount,0), isnull(Bank,'') FROM ORDetails
where OR_no=@or

SamC
White Water Yakist

3467 Posts

Posted - 2005-05-31 : 10:14:25
Can't answer this without knowing if you're displaying it in ASP, .NET or just the recordset data.

Column values must be of the same type. NULL is typeless, so NULL can appear in a DATETIME column. '' (VARCHAR type) cannot.

You could convert the entire column to VARCHAR, then substitute ''...

For example

ELECT OR_no, InvoiceNumber,
PaymentType, AmountPaid, isnull(CheckNumber,''),
IsNULL(CAST(CheckDate AS VARCHAR), '')

Or, get even fancier using CONVERT...
Go to Top of Page

vivek.kumargupta
Starting Member

45 Posts

Posted - 2005-06-01 : 01:21:26
Convert checkdate to varchar and apply isnull condition as in "select isnull(cast(checkamount as varchar(100)),0) from ORDetails" same with checkamount but dont cast it only use isnull(CheckAmount,0.0).

Thanks,
Vivek
Go to Top of Page
   

- Advertisement -