Typeconversion
Moderators: chulett, rschirm, roy
Typeconversion
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
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Thanks vamsi but my input data format isvamsi.4a6 wrote:Try this one StringToDate(string,"%dd%mm%yyyy")
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
Code: Select all
StringToDate(RIGHT('0':string,8),"%dd%mm%yyyy")
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
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.
Code: Select all
%(d,s)/%(m,s)/%yyyy
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
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?
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?