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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datetime field

Status
Not open for further replies.

rjhe22

Programmer
Jul 1, 2009
7
0
0
GB
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))

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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top