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!

Dbase IV - Remove the last 3 digits from a numeric field 2

Status
Not open for further replies.

CompExlsk

IS-IT--Management
Nov 27, 2012
8
Our Country is about to re-base its currency (Zambia). I want to remove the last three zeroes in a numeric field. Is there a single command that can be used at the command prompt to remove the last three zeroes in a column from all the records. Please Help. Thanks.
 
Thanks, I am new to dbase. What would be the command to divide all the fields in a column by 1000.
 

Where am I going wrong....

SET STATUS ON
SET SAFETY OFF
CLOSE ALL

USE EXCLUSIVE MASTER1
INDEX ON REF_NO TO MASTER1
DO WHILE .NOT. EOF()
IF STAT='C'.AND. AMT1 >= 1000
NEWAMT1=AMT1/1000
REPLA AMT1 WITH NEWAMT1
ENDIF
ENDDO

 
Replace Amt1 with Amt1/1000 for Stat = 'C' and Amt1 >= 1000


Ali Koumaiha
TeknoSoft Inc.
Michigan
 

This also worked for me and I can run this for a lot of columns at one go....

USE EXCLUSIVE MASTER1
INDEX ON REF_NO TO MASTER1
DO WHILE .NOT. EOF()
IF STAT='C'.AND. AMT1 >= 1000
NEWAMT1=AMT1/1000
REPLA AMT1 WITH NEWAMT1
SKIP
ELSE
SKIP
LOOP
ENDIF
ENDDO
CLOSE DATABASE
SET DEVICE TO SCREEN
CLEAR
SET STATUS OFF
RETURN
 
I have a serious concern about this portion of code:
Code:
 .AND. AMT1 >= 1000

Here's my reason for concern. Imagine you have two values of the old currency, 900 and 1000. After running your code you will have 900 (unchanged) and 1 (changed). Do you see that all numbers less than 1000 would remain unchanged? Unless you are deleting all the old values under 1000 first, I suggest you determine whether it's better just to update ALL such records in the applicable fields, not just the ones with amounts 1000 and higher.

Remember, your question was "to remove the last three zeroes in a column from ALL the records.
 
Thanks...for pointing that out...lucky... I had negative amounts as well
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top