Page 1 of 1

Date conversion Error

Posted: Sun Apr 25, 2010 1:05 pm
by myukassign
Hi,

I have a source datacolumn seldate in the form of 99991231 coming from a flatfile. Length of this field is varchar 8

I have to insert that to DB2 table using a DB2 enterprise stage. I am following the steps below.

1 In the derivation of transformer stage I am using the following function.

StringToDate(incolumn,'%yyyy%mm%dd') and My target column datatype is Date....


Everything fine...I am getting output also but the issue is I am getting a disturbing warning though I think I did all right.. Please can anyone tell me what is the reason for this warning.

APT_CombinedOperatorController(0),0: Conversion error calling conversion routine date_from_string data may have been lost

Re: Date conversion Error

Posted: Sun Apr 25, 2010 4:16 pm
by sohasaid
You might miss dashes, try this:

StringToDate(incolumn,'%yyyy-%mm-%dd')

Re: Date conversion Error

Posted: Sun Apr 25, 2010 4:18 pm
by sohasaid
You might miss dashes, try this:

StringToDate(incolumn,'%yyyy-%mm-%dd')

Re: Date conversion Error

Posted: Sun Apr 25, 2010 6:46 pm
by myukassign
sohasaid wrote:You might miss dashes, try this:

StringToDate(incolumn,'%yyyy-%mm-%dd')
Not actully. Since my input source don't have the format 9999-12-31, I did not use that format. Any help

Re: Date conversion Error

Posted: Mon Apr 26, 2010 12:05 am
by zulfi123786
myukassign wrote:Hi,

APT_CombinedOperatorController(0),0: Conversion error calling conversion routine date_from_string data may have been lost
The above warning comes when DataStage encounters a string that cannot be converted to date for example "99991331"---->here month is 13 which is invalid
To handle this situation do nt blindly convert dates use IsValid('Date',<column name>) function as shown below.

If IsValid('Date',<column name>) then StringToDate(incolumn,'%yyyy%mm%dd') else SetNull()

Posted: Mon Apr 26, 2010 12:21 am
by satish.raghavan
Check in the flat file for conversion to date. Declare the variable as DATE in the MATEDATA during extraction through Flat file and goto FORMAT-->DATE-->FORMAT STRING and give the format of incoming date there as YYYYMMDD or YYYY-MM-DD.
Note the incoming string is VARCHAR datatype but the date conversion will happen when you have mentioned the same coulmn as DATE in the Metadata and date format as specified.

This would work for a Flat file i hope.

Thanks and regards,

Posted: Tue Apr 27, 2010 12:00 am
by myukassign
yes its working... I put validity chk