Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query/400 1

Status
Not open for further replies.

os400

MIS
Mar 20, 2003
129
0
0
US
Using Query/400 how do you create a result field that is numeric from a character field. ex. fld1 = "124" char and I want to make it fld1Num = 124 numeric. I've played with the value and digits functions so far.



Tia

Mike Butler
Iseries Guy -> PC's gone, SUNs gone - WooHoo
"Never put off 'til tomorrow what you should have done yesterday
 
The only way I know of is to use the microsecond function. This only works if your character field is fixed length, otherwise, you'll need to substring the character field and add the digits back togethter at the end. (a*1000+b*100+c*10+d) for a 4 digit number.

CHARFIELD SUBSTR(INFIELD, 1,3)

NEWFLDTMP '2006-07-01-01.02.03.000'||CHARFIELD

INTFIELD MICROSECOND(NEWFLDTMP)

The microseconds on the fake timestamp I created is a max of six digits. The above will only work for a three digit field. If you are using a 1 digit field, then the timestamp will look like this...'2006-07-01-01.02.03.00000'.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top