I need to be able to add .0 to integer numbers in access query. Please see example below
Current Table
61
61.5
68.0
70
72.5
84
What I would like the table to look like
61.0
61.5
68.0
70.0
72.5
84.0
The format of the field is text and would have to stay that way unfortunately due to a submission procedure we have to follow.
Any ideas are greatly appreciated.
You talk of a query but you do not mention much detail about it.
As long as the column you are formating is a numeric data type only, then you can use:
SELECT Format([columnName], "0.0") FROM tableName);
Related
Did not found anything to solve this.
I'm doing some easy things on an Access Database 2007 32 bit.
Got this table:
Id_iva Desde Hasta Valor_Iva
2 01/01/2000 31/08/2012 18,00%
4 01/09/2012 31/12/2021 21,00%
5 01/01/2022 31/12/2099 25,00%
Valor_iva is a numeric field, single type. I manually input those numbers, with 2 decimals only (in this case all of them are 0, but it could be something like 18,50% or 20,23% and so on)
If I make a query like this:
SELECT T_IVA.Hasta, T_IVA.Valor_Iva FROM T_IVA;
It works as expected and it returns exactly the values:
But If my query is this:
SELECT T_IVA.Hasta, Sum(T_IVA.Valor_Iva) AS SumaDeValor_Iva FROM T_IVA GROUP BY T_IVA.Hasta;
I get extradecimals in some values.
Can't understand where those decimals come from.
I've googled about CAST and TRUNCATE but I could not apply those (or I don't know how to).
WHAT I WANT: I just want to make a GROUP BY query that does not add those decimals.
Thanks in advance.
If you want exact results, then cast to an exact type before doing any operations. Or, even better, use an exact (non-floating point) type in the first place.
It seems your values fit in the Currency data type. The Decimal data type can be used for larger values with decimals.
SELECT T_IVA.Hasta, Sum(CCur(T_IVA.Valor_Iva)) AS SumaDeValor_Iva FROM T_IVA GROUP BY T_IVA.Hasta;
I have 2 problems (similar to each other)
Problem 1:
I have a column in my table named dateofstart.
2017-09-13 09:55:02.000
2017-09-03 09:33:12.000
I need to convert it to
2017-09-13 09:55
2017-09-03 09:33
The problem 2 is the date format is a little bit different.(another table/column)
2017-9-13 09:55:02.000
2017-9-3 09:33:12.000
how can I convert those to without seconds and ms
I have tried some related questions on SO. but failed
some of them removed last numbers or allowed certain chars (the problem is I have 2 different formats)
There is a reason why they use different formats(something with the application) but now I have a problem where I have 2 find an answer that will work for both of them
probably this can help you i guess.
Write this query in the inner query,
SELECT DATE_FORMAT(column_name, '%m/%d/%Y %H:%i') FROM tablename;
I'm migrating data over from one database to another, and am writing the appropriate scripts. I want to start on a clean slate and fix a lot of the inconsistent formatting allowed by the previous app, specifically with prices, the following all being examples of prices currently stored in the previous database:
-100.00
700.00
0.01
3,200.00
3200
1,750.5
0
500/hour
I would like to convert everything into cents, so the above would be:
-10000
70000
1
320000
320000
175050
0
50000
I was hopeful when FORMAT(price, 2) * 100 seemed to work on a lot of them, including (!) 500/hour:
select format('500/hour', 2) * 100;
-> 50000
But for some reason, I'm getting weird results for 3200.00:
select format('3200.00', 2) * 100;
-> 300
While writing this, It appears that it doesn't work for any numeric strings above 1,000, and I'm guessing it has something to do with the presence/lack of a comma. Is there any intelligent way to parse the above examples into cents? If it is simple enough, I'd love to just incorporate it into the select query, but a user defined function is also fine.
You could first remove the comma with this sentence:
replace(data,',','')
This could be because you have a varchar type instead of an int type. If you do
select cast(replace('3,200.00',',','') as signed) * 100
It should work
In a mysql table i have column whit this info..
Col.
tr10
tr210
zbr10
00010
10010
tr 10
The question is simple, i need to find in a mysql query all the records number 10.. but as you can see in the example not 10010 etc..
Result:
tr10
zbr10
00010
tr 10
I know is a mess but the records had to be load in that form..
so you have characters at the begining, in some cases spaces, or zeros..
An option could be extract (by hand) hundred of characters to another column to keep the things less complex, but at the same time i still having problems with the 000010 values..
Use regular expressions
select * from table where col regexp '^[a-z]+10$'
Play with the regex until you get your desired results, i didnt fully understand you criteria so I just made one up but the one in my example will pull all the rows with any alpha characters proceeded by 10
What if I wanted to define a custom column format in MySQL? The custom format that I want is always a 2 digit integer, followed by the # sign, then a space, then a decimal number with 2 digits after the decimal. Examples of allowed values are like this:
30# 11.00
27# 17.25
40# 17.25
values that are not allowed are like this:
30# 11
40# 20.5
some string
Is this possible in MySQL? If so, any hints on how to do it?
well since "The CHECK clause is parsed but ignored by all storage engines." in mysql, your only remaining option would be to add a before insert/update trigger on your table to regexp your input and proceed.