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 2005 Forums
 SSIS and Import/Export (2005)
 NULL for Date data type ?

Author  Topic 

Ali Chadorbaf
Starting Member

44 Posts

Posted - 2007-10-23 : 21:03:07
Hi,
I created a function class in "Script Components" to convert an Integer to a Date data type. It works good except that it converts NULL value to the date 1988-12-31; but I want to return NULL when the value is NULL. Any idea on this?

Here is my function:

Public Class ScriptMain
Inherits UserComponent

Private Function ConvertToDate(ByVal dateIn As Double) As Date
Dim DateStr as String
...........
...........
If DateStr Is Nothing Then
Return Nothing
Else
Return CDate(DateStr)
End If
End Function

Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Row.ReportDte = ConvertToDate(Row.RPRTDT)
End Sub
End Class

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-24 : 01:34:06
Then you can't have double as datatype for function.´
You have to use Variant instead that can hold NULL value.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-24 : 01:51:10
Also you need to function datatype to be variant.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-24 : 02:56:04
Cant you apply the function only if the value is not null?

case when value is not null then Function_call else NULL end


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -