Date conversion warning

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
bollinenik
Participant
Posts: 111
Joined: Thu Jun 01, 2006 5:12 am
Location: Detroit

Date conversion warning

Post by bollinenik »

Hi,
I am trying to ocnvert 6 digit value like 'yymmdd' value into actual date format like 'yyyy-mm-dd', I am able to do it by using below function but it's throowing below warning, Can anyone help me to stop that warning.

function : StringToDate(GLTxnread.NW_WRK_DT_SRC_ORIG,"%yy%mm%dd")

Warning: GLTxn_tfm_1,1: Conversion error calling conversion routine date_from_string data may have been lost
How to avoid this warning.
Thanks in advance.
f.hq
Participant
Posts: 3
Joined: Mon Jan 25, 2010 6:59 am

Re: Date conversion warning

Post by f.hq »

hi,
using StringToDate(GLTxnread.NW_WRK_DT_SRC_ORIG,"2000%yy%mm%dd") works. But, the warning appears if the field has some invalid value. Example: "AA1253".
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Actually, it should be

Code: Select all

StringToDate(GLTxnread.NW_WRK_DT_SRC_ORIG,"20%yy%mm%dd") 
for dates in 2000 and the conversion without the century values uses the default system setttings.

If you have invalid non-date values, then you should add a call to the function IsValid() to determine whether or not you have a valid date before converting it.
f.hq
Participant
Posts: 3
Joined: Mon Jan 25, 2010 6:59 am

Post by f.hq »

ArndW wrote:Actually, it should be

Code: Select all

StringToDate(GLTxnread.NW_WRK_DT_SRC_ORIG,"20%yy%mm%dd") 
for dates in 2000 and the conversion without the century values uses the default system ...
hi,
anybody khows how to avoid or treat the warning when the field has some invalid value using StringToDate?

The function isValid doesn't works because the input field are yymmdd and the default project value are yyyymmdd.

When I include StringToDate, it's works, but with warnings on the invalid field values.

thanks
kpsita
Participant
Posts: 99
Joined: Tue Jul 21, 2009 11:43 pm

Post by kpsita »

I had similar issues. So I first created a stage variable with the input date field to know if it is a valid entry or not. For eg if my input is 01-01-2001, then I created a stage variable with if else condition substring(1,2) = '-', substring(4,5) = '-' .
KPSITA
kpsita
Participant
Posts: 99
Joined: Tue Jul 21, 2009 11:43 pm

Post by kpsita »

In your case for yyyymmdd, you can create a stage variable with following condition. substring(1,4) is between 0001-9999, substring(5,2) is between 01-12 and substring(7,2) is between 01-31.

hope this helps
KPSITA
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

f.hq wrote: The function isValid doesn't works because the input field are yymmdd and the default project value are yyyymmdd.
Then insert a "20" on the front and push it through IsValid...
vivekgadwal
Premium Member
Premium Member
Posts: 457
Joined: Tue Sep 25, 2007 4:05 pm

Post by vivekgadwal »

f.hq wrote:
ArndW wrote:Actually, it should be

Code: Select all

StringToDate(GLTxnread.NW_WRK_DT_SRC_ORIG,"20%yy%mm%dd") 
for dates in 2000 and the conversion without the century values uses the default system ...
hi,
anybody khows how to avoid or treat the warning when the field has some invalid value using StringToDate?

The function isValid doesn't works because the input field are yymmdd and the default project value are yyyymmdd.

When I include StringToDate, it's works, but with warnings on the invalid field values.

thanks
Can't you just check whether the input string is numeric first and then pass it into the IsValid() function?

Code: Select all

stagevariable1 = Num(<Field>)

stagevariable2 = If stagevariable1 Then IsValid(...) Else <Reject>
Let us know if this approach works!
Vivek Gadwal

Experience is what you get when you didn't get what you wanted
f.hq
Participant
Posts: 3
Joined: Mon Jan 25, 2010 6:59 am

Post by f.hq »

Hi,

thanks all.

My Isvalid function are:

Isvalid("date","20":link.field[1,2]:"-":link.field[3,2]:"-":link.field[5,2])


[]'s
Post Reply