remove only decimal place and not comma - decimal

Please i have 123,788.98, I want to remove the decimal place before storing in dbase so as to have just 123,789.
I tried round(123,789.98) but it gives me just 123.
Please how can remove the decimal place without removing the comma?

Divided with comma, these are two numbers. 123 and 788.98. So just round(788.98) and insert them both in one row.
INSERT INTO table(row) VALUES ('123,'.round(788.98).'')
If you have a comma, you can create two variables from the form input:
list($one, $two) = explode(",", "S_POST['amount']", 2);

Related

How to extract text from a string between where there are multiple entires that meet the criteria and return all values

This is an exmaple of the string, and it can be longer
1160752 Meranji Oil Sats -Mt(MA) (000600007056 0001), PE:Toolachee Gas Sats -Mt(MA) (000600007070 0003)GL: Contract Services (510000), COT: Network (N), CO: OM-A00009.0723,Oil Sats -Mt(MA) (000600007053 0003)
The result needs to be column1 600007056 column2 600007070 column3 600007053
I am working in Spotfire and creating calclated columns through transformations as I need the columns to join to other data sets
I have tried the below, but it is only picking up the 1st 600.. number not the others, and there can be an undefined amount of those.
Account is the column with the string
Mid([Account],
Find("(000",[Account]) + Len("(000"),
Find("0001)",[Account]) - Find("(000",[Account]) - Len("(000"))
Thank you!
Assuming my guess is correct, and the pattern to look for is:
9 numbers, starting with 6, preceded by 1 opening parenthesis and 3 zeros, followed by a space, 4 numbers and a closing parenthesis
you can grab individual occurrences by:
column1: RXExtract([Amount],'(?<=\\(000)6\\d{8}(?=\\s\\d{4}\\))',1)
column2: RXExtract([Amount],'(?<=\\(000)6\\d{8}(?=\\s\\d{4}\\))',2)
etc.
The tricky bit is to find how many columns to define, as you say there can be many. One way to know would be to first calculate a max number of occurrences like this:
maxn: Max((Len([Amount]) - Len(RXReplace([Amount],'(?<=\\(000)6\\d{8}(?=\\s\\d{4}\\))','','g'))) / 9)
still assuming the number of digits in each column to extract is 9. This compares the length of the original [Amount] to the one with the extracted patterns replaced by an empty string, divided by 9.
Then you know you can define up to maxn columns, the extra ones for the rows with fewer instances will be empty.
Note that Spotfire always wants two back-slash for escaping (I had to add more to the editor to make it render correctly, I hope I have not missed any).

Excel - remove characters after a specific character

I have colum B with values:
0015-04D-SEAW
0015-ADLKM-SPOK
0015-D-CURR
0016-01N-BOIL
etc.
How can I remove all characters after second dash and the second dash itself as well, it should look like this:
0015-04D
0015-ADLKM
0015-D
0016-01N
Assuming B1 contains 0015-04D-SEAW
This would do : =IFERROR(MID(B1,1,FIND("-",B1,FIND("-",B1,1)+1)-1),B1)
Result : 0015-04D
One dirty solution would be to convert text to columns delimited by - and then to concatenate the first two columns separated by -

Find space in a list

I have a list (below) that is the output from an Excel table. The Excel table has 3 columns: Month, Col1, Col2 and the output format is CSV.
January,630648,97646 February,576204,87616 March,998287,142008 April,782340,118664 May,1678775,205862 June,1976671,295065 July,3349937,438844 August,0,0 September,0,0 October,0,0 November,0,0 December,0,0
I want to display this as an HTML table. I tried using List and Array functions, but could not achieve the desired result. How can I change the empty space to a delimiter, or is there a better way to do this?
Update from comments:
I am using cfspreadsheet to read an excel table with 3 columns
<cfspreadsheet src="../../../../file.xlsx"
action="read"
name="myquery"
sheetname="2014"
rows="6-17" columns="10,11,12"
format="csv"
columnnames="Month,Col1,Col2"
headerrow="4"
excludeheaderrow="false">
When I used the replace function; it did not do anything to the list. I then tried ListChangeDelims as suggested. However, that just changed the , to ; but the space remained as it is.
A list is just a string, so use one of the string functions.
replace(myString," ",";","all")
will replace all the spaces in the string with semi-colons.
You could also use ListChangeDelims() and convert the spaces to the delimiter that you want.
ListChangeDelims(list, new_delimiter [, delimiters, includeEmptyValues ])
So, this would change spaces and commas to semi-colons:
ListChangeDelims(myList,";",", ")
It's important to have both the space and the comma in the delimiters attribute.

=IF(ISNUMBER(SEARCH.... the difference between 1 and 11

I am trying to convert a single column of numbers in excel to multiple depending on the content.
e.g. Table 1 contains 1 column that contains 1 or more numbers between 1 and 11 separated with a comma. Table 2 should contain 11 columns with a 1 or a 0 depending on the numbers found in Table 1.
I am using the following formula at present:
=IF(ISNUMBER(SEARCH("1",A2)),1,0)
The next column contains the following:
=IF(ISNUMBER(SEARCH("2",A2)),1,0)
All the way to 11
=IF(ISNUMBER(SEARCH("11",A2)),1,0)
The problem with this however is that the code for finding references to 1 also find the references to 11. Is it possible to write a formula that can tell the difference so that if I have the following in Table 1:
2, 5, 11
It doesn't put a 1 in column 1 of Table 2?
Thanks.
Use, for list with just comma:
=IF(ISNUMBER(SEARCH(",1,", ","&A2&",")),1,0)
If list is separated with , (comma+space):
=IF(ISNUMBER(SEARCH(", 1,", ", "&A2&",")),1,0)
A version of LS_dev's answer that will cope with 0...n spaces before or after each comma is:
=IF(ISNUMBER(SEARCH(", 1 ,",", "&TRIM(SUBSTITUTE(A2,","," , "))&" ,")),1,0)
The SUBSTITUTE makes sure there's always at least one space before and after each comma and the TRIM replaces multiple spaces with one space, so the result of the TRIM function will have exactly one space before and after each comma.
How about using the SUBSTITUTE function to change all "11" to Roman numeral "XI" prior to doing your search:
=IF(ISNUMBER(SEARCH("1",SUBSTITUTE(A2, "11", "XI"))),1,0)
If you want to eliminate "11" case, but this is all based on hardcoded values, there should be a smarter solution.
=IF(ISNUMBER(SEARCH(AND("1",NOT("11")),A2)),1,0)

concatenating unknown-length strings in COBOL

How do I concatenate together two strings, of unknown length, in COBOL? So for example:
WORKING-STORAGE.
FIRST-NAME PIC X(15) VALUE SPACES.
LAST-NAME PIC X(15) VALUE SPACES.
FULL-NAME PIC X(31) VALUE SPACES.
If FIRST-NAME = 'JOHN ' and LAST-NAME = 'DOE ', how can I get:
FULL-NAME = 'JOHN DOE '
as opposed to:
FULL-NAME = 'JOHN DOE '
I believe the following will give you what you desire.
STRING
FIRST-NAME DELIMITED BY " ",
" ",
LAST-NAME DELIMITED BY SIZE
INTO FULL-NAME.
At first glance, the solution is to use reference modification to STRING together the two strings, including the space. The problem is that you must know how many trailing spaces are present in FIRST-NAME, otherwise you'll produce something like 'JOHNbbbbbbbbbbbbDOE', where b is a space.
There's no intrinsic COBOL function to determine the number of trailing spaces in a string, but there is one to determine the number of leading spaces in a string. Therefore, the fastest way, as far as I can tell, is to reverse the first name, find the number of leading spaces, and use reference modification to string together the first and last names.
You'll have to add these fields to working storage:
WORK-FIELD PIC X(15) VALUE SPACES.
TRAILING-SPACES PIC 9(3) VALUE ZERO.
FIELD-LENGTH PIC 9(3) VALUE ZERO.
Reverse the FIRST-NAME
MOVE FUNCTION REVERSE (FIRST-NAME) TO WORK-FIELD.
WORK-FIELD now contains leading spaces, instead of trailing spaces.
Find the number of trailing spaces in FIRST-NAME
INSPECT WORK-FIELD TALLYING TRAILING-SPACES FOR LEADING SPACES.
TRAILING-SPACE now contains the number of trailing spaces in FIRST-NAME.
Find the length of the FIRST-NAME field
COMPUTE FIELD-LENGTH = FUNCTION LENGTH (FIRST-NAME).
Concatenate the two strings together.
STRING FIRST-NAME (1:FIELD-LENGTH – TRAILING-SPACES) “ “ LAST-NAME DELIMITED BY SIZE, INTO FULL-NAME.
You could try making a loop for to get the real length.

Resources