November 12, 2008 at 9:28 am
isnull(A.Account_Established_Date, CONVERT(nvarchar(23), GETDATE(), 121))
is giving me:
2008-11-12
but i need to look like this:
2008-11-12 10:23:43.600
when i run this way it works:
CONVERT(nvarchar(23), GETDATE(), 121)
November 12, 2008 at 9:34 am
Assuming that Account_Established_Date is defined as a datetime datatype, what happens when you use this:
isnull(A.Account_Established_Date,gedate())
November 12, 2008 at 9:37 am
i get this:
Nov 12 200
November 12, 2008 at 9:51 am
Appears that A.Account_Established_Date is not defined as a datetime, but perhaps nvarchar(10). Try this:
coalesce(A.Account_Established_Date, CONVERT(nvarchar(23), GETDATE(), 121))
November 12, 2008 at 10:31 am
Here is some test code for you to check out.
declare @SDate nvarchar(10),
@SDateNull nvarchar(10),
@DDate datetime;
set @SDate = N'2008/10/12';
set @DDate = getdate();
select
@SDate,
@SDateNull,
@DDate,
isnull(@SDateNull,@DDate),
coalesce(@SDateNull,@DDate);
On my system, this is what was returned from the above:
---------- ---------- ----------------------- ---------- -----------------------
2008/10/12 NULL 2008-11-12 10:34:05.233 Nov 12 200 2008-11-12 10:34:05.233
(1 row(s) affected)
November 12, 2008 at 10:33 am
thanks
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply