f



Query/400 String to nummeric

Hi!

I've got a problem converting a string value in a nummeric value:
converting nummerin ino string is not a problem
field1    digits(field2)

does anybody know the other way?

Thanks 
Michael
0
7/2/2003 9:28:45 AM
comp.sys.ibm.as400.misc 9218 articles. 2 followers. Post Follow

4 Replies
5005 Views

Similar Articles

[PageSpeed] 1

"Michael" <jovicevic_m@dsdohmen.de> a �crit dans le message de news: ca50984b.0307020128.14ae06b7@posting.google.com...
> Hi!
>
> I've got a problem converting a string value in a nummeric value:
> converting nummerin ino string is not a problem
> field1    digits(field2)
>
> does anybody know the other way?
>
> Thanks
> Michael

Maybe you can find a workaround in the embedded SQL statements of a Qmqry instead.
Use RTVQMQRY and CRTQMQRY commands and allow information from your QRYDFN.
HTH
Mercury


0
7/2/2003 1:13:12 PM
If you're using SQL maybe something like this would help:
SELECT field1, CAST(field2 as CHAR(10)) AS charfield2 FROM mytable

> I've got a problem converting a string value in a nummeric value:
> converting nummerin ino string is not a problem
> field1    digits(field2)
0
budimlic (202)
7/2/2003 2:55:58 PM
Michael wrote:
> I've got a problem converting a string value in a nummeric value:
> converting nummerin ino string is not a problem
> field1    digits(field2)
>
> does anybody know the other way?

http://mcpressonline.com/mc?14@44.6Tfxazekbxg.6@.f00945e/4

Bill


0
7/2/2003 10:08:59 PM
"Bill Z Bubb" <billzbubbXXX@netscape.net> wrote in message news:<bdvl4v$11ktq1$1@ID-91878.news.dfncis.de>...
> Michael wrote:
> > I've got a problem converting a string value in a nummeric value:
> > converting nummerin ino string is not a problem
> > field1    digits(field2)
> >
> > does anybody know the other way?
> 
> http://mcpressonline.com/mc?14@44.6Tfxazekbxg.6@.f00945e/4
> 
> Bill

CONVERTING CHARACTER DATA TO NUMERIC IN QUERY/400
Query/400 does not provide a native method for converting character data to 
numeric, but with the following hack, the conversion is possible. I have a 
character field (four digits) that's used for generic purposes in a 
particular database file. Although the field's format is character, the 
field sometimes represents numeric data. To perform math operations on such 
data in Query, you must first convert the field to numeric. By using the 
MICROSECOND keyword in the Define Result Fields section of Query, you can 
convert the character data to a numeric field for later use in calculations.

For example, create a field called TIMESTAMP using Query's Define Result 
Fields panel, specifying 

'1988-12-25-17.30.00.00' || CHARFIELD4

in the panel's Expression column. The field CHARFIELD4 in this example 
represents a four-digit character field containing the characters 0 (zero) 
through 9 (nine).

Next, use the MICROSECOND keyword on the TIMESTAMP field to create a numeric 
copy of CHARFIELD4's character data. Here's what the Define Result Fields 
panel will look like:

Field     Expression                           Column Heading Len Dec
TIMESTAMP '1988-12-25-17.30.00.00' || CHARFIELD4               26
NUMERIC6  MICROSECOND(TIMESTAMP)                                6   0

The MICROSECOND keyword takes the six rightmost digits in the TIMESTAMP 
field and converts them to numeric. In the example, the character field is 
only four digits long, so 00 is concatenated with the character field to 
create a valid timestamp with six digits of milliseconds.

If a given character field is larger than six digits, you'll need to break 
down the above process into multiple steps and perform a math operation on 
the individual numeric components to combine them.
2
7/4/2003 3:17:21 PM
Reply:

Web resources about - Query/400 String to nummeric - comp.sys.ibm.as400.misc

Resources last updated: 3/24/2016 5:14:29 PM