Trouble with StringToDate
Moderators: chulett, rschirm, roy
Trouble with StringToDate
Hi,
Here my situation:
Input schema:
col_1 integer nullable
col_2 varchar nullable
Output schema:
col_1 integer nullable
col_2 date nullable
When i convert "col_2" into datatype 'Date' with the code "StringToDate(col_2,"%yyyy%mm%dd")", i have the warning "Conversion error calling conversion routine date_from_string data may have been lost ".
But i have this warning only if my column "col_2" contains null.
If this column contains no null value, i have no warning.
I do some test to do conversion only if col_2 is not null but i still have this warning.
How i can avoid this warning ? (is it human trouble or engine mistake)
Here my situation:
Input schema:
col_1 integer nullable
col_2 varchar nullable
Output schema:
col_1 integer nullable
col_2 date nullable
When i convert "col_2" into datatype 'Date' with the code "StringToDate(col_2,"%yyyy%mm%dd")", i have the warning "Conversion error calling conversion routine date_from_string data may have been lost ".
But i have this warning only if my column "col_2" contains null.
If this column contains no null value, i have no warning.
I do some test to do conversion only if col_2 is not null but i still have this warning.
How i can avoid this warning ? (is it human trouble or engine mistake)
Re: Trouble with StringToDate
Show us.Obiwon666 wrote:I do some test to do conversion only if col_2 is not null but i still have this warning.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Code: Select all
If IsNotNull(Ln_in.col_2) Then StringToDate(Ln_in.col_2,"%yyyy%mm%dd") Else SetNull()
I use this code and it works.
Code: Select all
If IsNotNull(Ln_in.col_2) or Ln_in.col_2 ="" Then StringToDate(Ln_in.col_2,"%yyyy%mm%dd") Else SetNull()
It does? To me, that pushes empty string to the StringToDate which was said to be the cause of the error...Obiwon666 wrote:So it was a human problem.Code: Select all
If IsNotNull(Ln_in.col_2) or Ln_in.col_2 ="" Then StringToDate(Ln_in.col_2,"%yyyy%mm%dd") Else SetNull()
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
I make a mistake when i write the code.
Yes when i use len function, i have 0.
Pb for my job it's why i have no null values. My column is nullable.
Anyway my warning problem is solved.
For your information:
I made a test to know what do len with a null value in a column, the results is a warning "APT_CombinedOperatorController,1: Field 'Col_2' from input dataset '0' is NULL. Record dropped. [transform/tfmop_functions.C:184]"
If I add "If IsNull(Ln_in.Col_2) Then SetNull() Else Len(Ln_in.Col_2)", i have no warning and no row dropped
![Embarassed :oops:](./images/smilies/icon_redface.gif)
Code: Select all
Good code :
If IsNull(Ln_in.col_2) Or Ln_in.col_2="" Then SetNull() Else StringToDate(Ln_in.col_2,"%yyyy%mm%dd")
Pb for my job it's why i have no null values. My column is nullable.
Anyway my warning problem is solved.
For your information:
I made a test to know what do len with a null value in a column, the results is a warning "APT_CombinedOperatorController,1: Field 'Col_2' from input dataset '0' is NULL. Record dropped. [transform/tfmop_functions.C:184]"
If I add "If IsNull(Ln_in.Col_2) Then SetNull() Else Len(Ln_in.Col_2)", i have no warning and no row dropped
-
- Participant
- Posts: 32
- Joined: Tue Dec 13, 2011 7:27 am