Page 1 of 1
Typeconversion
Posted: Mon Aug 13, 2012 5:18 am
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
Posted: Mon Aug 13, 2012 5:29 am
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.
Posted: Mon Aug 13, 2012 6:04 am
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
Posted: Mon Aug 13, 2012 6:24 am
by vamsi.4a6
Try this one StringToDate(string,"%dd%mm%yyyy")
Posted: Mon Aug 13, 2012 6:37 am
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
Posted: Mon Aug 13, 2012 6:53 am
by ArndW
Code: Select all
StringToDate(RIGHT('0':string,8),"%dd%mm%yyyy")
Posted: Mon Aug 13, 2012 6:59 am
by ntr
Hi ArndW,
I am not getting what above logic is can please explain little bit
Posted: Mon Aug 13, 2012 7:07 am
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:
Would handle a leading space or zero for the day and month segments.
Posted: Mon Aug 13, 2012 7:08 am
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?
Posted: Mon Aug 13, 2012 7:19 am
by ntr
Hi ShaneMuir,
I am doing this in columderivation
my input datatype is varchar8
output is date
Thanks
Posted: Mon Aug 13, 2012 7:21 am
by chulett
And... do you have it working now?
Posted: Mon Aug 13, 2012 7:29 am
by ntr
Its working thanks to all i had written as ArndW said
Thanks