Typeconversion

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
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Typeconversion

Post by ntr »

Hi,

while converting string to date iam getting warning

"Data string '9122011' does not match format '%dd-%mm-%yyyy': the value for tag %yyyy has fewer characters than expected."

because of above warning data of that field loading as ********

my input data format is(9122011)

coversion logic what i had return is
StringToDate(string,"%dd-%mm-%yyyy") i had checked by changig it as

StringToDate(string,"%d-%mm-%yyyy") no use same warning and data loding as ***** format only .i had searched in forum also i didnt get the solution can any one please suggest me how to resolve this

Thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You have a single digit day part. Your mask specifies two digits for day. How does your data represent 8 Aug 2011 and 28 Aug 2011. You need to organise matters such that the format of the string you're converting matches the specification given in the conversion function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Post by ntr »

Hi ray,

my input if it aug 2 then the format is "2082011"

if it is aug28 then the format is "28082011"


Thanks
vamsi.4a6
Participant
Posts: 334
Joined: Sun Jan 22, 2012 7:06 am
Contact:

Post by vamsi.4a6 »

Try this one StringToDate(string,"%dd%mm%yyyy")
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Post by ntr »

vamsi.4a6 wrote:Try this one StringToDate(string,"%dd%mm%yyyy")
Thanks vamsi but my input data format is

if it aug 2 then the format is "2082011"

if it is aug28 then the format is "28082011"

for that i had return StringToDate(string,"%dd%mm%yyyy")

and StringToDate(string,"%d%mm%yyyy")

but those are not working can please suggest me how to write syntax for that

Thanks
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Code: Select all

StringToDate(RIGHT('0':string,8),"%dd%mm%yyyy")
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Post by ntr »

Hi ArndW,

I am not getting what above logic is can please explain little bit
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I disabled the smilie, might help. You can also look into the 's' option for dates which allow leading spaces and zeroes to be handled. For example:

Code: Select all

%(d,s)/%(m,s)/%yyyy
Would handle a leading space or zero for the day and month segments.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

ArndW is ensuring that the input string will be 8 characters long by adding a '0' to the front of the input string and then keeping only the 8 right-most characters. This will ensure that your input field matches the pattern %dd%mm%yyyy

Just another quick question for the sake of completeness? Are you doing this conversion in a stage variable and what are your input and output column types?
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Post by ntr »

Hi ShaneMuir,

I am doing this in columderivation

my input datatype is varchar8

output is date

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And... do you have it working now?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Post by ntr »

Its working thanks to all i had written as ArndW said


Thanks
Post Reply