Page 1 of 1

Date conversion warning

Posted: Wed May 20, 2009 11:56 am
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.

Re: Date conversion warning

Posted: Mon Jan 25, 2010 8:00 am
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".

Posted: Mon Jan 25, 2010 8:15 am
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.

Posted: Tue Jan 26, 2010 6:39 am
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

Posted: Tue Jan 26, 2010 12:48 pm
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) = '-' .

Posted: Tue Jan 26, 2010 12:51 pm
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

Posted: Tue Jan 26, 2010 2:20 pm
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...

Posted: Tue Jan 26, 2010 6:48 pm
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!

Posted: Thu Jan 28, 2010 3:49 am
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