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!

*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.

Jobs

datetime field

datetime field

(OP)
hi
i have this code that does not seem to work with datetime fields in my expression can anyone tell me what i have to do to get it to work


ISNULL(BLOOM_ISSUE_DT) ? "1900-01-01" : UPPER(TRIM(BLOOM_ISSUE_DT))

RE: datetime field

(OP)
thses are the erros
TITLE: Microsoft Visual Studio
------------------------------

Error at Categorization [Derived Column [27562]]: Error code 0x80040E21 occurred attempting to convert from data type DT_WSTR to data type DT_DBTIMESTAMP2.

Error at Categorization [Derived Column [27562]]: Casting expression ""1900-01-01"" from data type "DT_WSTR" to data type "DT_DBTIMESTAMP2" failed with error code 0xC00470C2.

Error at Categorization [Derived Column [27562]]: Computing the expression "ISNULL(BLOOM_ISSUE_DT) ?(DT_DBTIMESTAMP2,7)"1900-01-01" : UPPER(TRIM(BLOOM_ISSUE_DT))" failed with error code 0xC00470C4. The expression may have errors, such as divide by zero, that cannot be detected at parse time, or there may be an out-of-memory error.

Error at Categorization [Derived Column [27562]]: The expression "ISNULL(BLOOM_ISSUE_DT) ?(DT_DBTIMESTAMP2,7)"1900-01-01" : UPPER(TRIM(BLOOM_ISSUE_DT))" on "input column "BLOOM_ISSUE_DT" (143906)" is not valid.

Error at Categorization [Derived Column [27562]]: Failed to set property "Expression" on "input column "BLOOM_ISSUE_DT" (143906)".



------------------------------
ADDITIONAL INFORMATION:

Exception from HRESULT: 0xC0204006 (Microsoft.SqlServer.DTSPipelineWrap)

------------------------------
BUTTONS:

OK
------------------------------


and i changed my line to
ISNULL(BLOOM_ISSUE_DT) ?(DT_DBTIMESTAMP2,7)"1900-01-01" : UPPER(TRIM(BLOOM_ISSUE_DT))

RE: datetime field

Hi,

The issue is that you are trying to trim and change case on a date time field. You need to cast/convert the date time to a char field before you can change the format. I am not sure what you were trying to achieve with making a date in uppercase?

If you are looking at trimming the timestamp from the date, you could convert to char then substring the 10 characters that make up the date component....

The other part in this derived column expression is what datatype is the result writing to? Assuming from your error that it is still expecting a timestamp output.

Not sure if that helped - but I am not sure what you are trying to achieve.

RE: datetime field

Just an update -
Change your datatype to a DT_STR length 10

ISNULL(BLOOM_ISSUE_DT) ? "1900-01-01" : (DT_STR,10,1250)(BLOOM_ISSUE_DT)

This will set null dates to your 1900 date, the string convert looks at first 10 characters and uses the ANSI code page 1250 for character set decode - but choose the one that suits you.

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!

Resources

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