×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Derived Column isnull with a date

Derived Column isnull with a date

Derived Column isnull with a date

(OP)
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

RE: Derived Column isnull with a date

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

RE: Derived Column isnull with a date

(OP)
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

RE: Derived Column isnull with a date

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close