Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Derived Column isnull with a date

Status
Not open for further replies.

TeamGD

IS-IT--Management
Feb 18, 2001
69
AU
In a Derived Column transformation I want to transform a date such that if it is a null then replace it with 1753-01-01 otherwise keep the date value. However I’m getting an error.

I’m using the following expression:

ISNULL( [hrs_client_dob] ) ? 1753-01-01 00:00:00.000 : [hrs_client_dob]

[hrs_client_dob] is being sourced from a SQL Server 2005 table and has datetime format.

The data type of the expression in the Derived Column transformation is DT_DBTimeStamp

I’ve tried double & single quotes around the date/time. I’ve tried it with no time values. I’ve tried different data types in the Derived Column transformation. All with no success.

What am I doing wrong?

Cheers

gmhm
 
When you are editing the Expression is it in RED or black?
Can you see the error?

 
Thanks for responding manmaria.

The expression is in red.

If I click on OK, the Microsoft Visual Studio error is:

Error at Dim_Client [Replace Nulls[1132]]: Attempt to parse the expression “ISNULL( [hrs_client_dob] ) ? 1753-01-01 00:00:00.000 : [hrs_client_dob]” failed. The expression might contain an invalid token, an incomplete token, or an invalid element. It might not be well-formed, or might be missing part of a required element such as a parenthesis.

Cheers

gmhm
 
manmaria ... I've since found the solution. I needed to cast the date as per below.

ISNULL(hrs_client_dob) ? (DT_DBTIMESTAMP)"1753-01-01 00:00:00.000" : hrs_client_dob

Thanks must go to manmaria in the SQLServerCentral.com forum.

Cheers

gmhm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top