I have an application where I can download data to excel file.
The problem is that I need to add euro sigh to some fields.
I had a simialar problem with date.
In excel it was 54656434
It changed in normal date after using convert(varchar,senddate,105)
Is there something that looks like that to add euro sign and round it to 2 decimals ???
EDIT:
In excel i get the number like 1,55435
I need the output be like € 1,55
This is kind of convoluted... let me know what you think. Replace '1,55435' with your field.
SELECT CONCAT('£', CAST(CAST(1,55435 AS DECIMAL(18,2)) AS CHAR(55)))
I'm in the US, so I'm not sure if decimals can be changed to use commas instead of periods.
Edit: Also, try this: SELECT CONCAT('£', FORMAT(1,55365, 2)). Let me know which works.
Related
am exporting a query table to a CSV file and its all working ok but my only problem is that the Salary Field is showing two decimals after the export that i dont want,what i tried so far is
1- reformat the field in the query to loose the decimals like this
Amount: Format(Salary,"0")
when i run the query (inside Access) there are no decimals but after the export they are still there
2- remove the decimals from (Region and Language) in the control panel(i dont like this approach) and the result is that the Zeros are gone but the decimal point still there.
Try to convert to long
Amount: CLng(Salary)
It was a faulty Office app,re installing it fixed the problem.
In a project I am working on, I have a column in my database named Amount. This is a money format, but there is no need for it to have a dollar sign in front.
I would like every value that is entered in here to be this format:
123456 -> 123,456.00
How can I achieve this?
No, the stored value should not be formatted, it should be stored as a plain number, otherwise you can't do any arithmetic calculations.
When the number is displayed, that's when you format its appearance either in the application layer (that's the preferred approach) or you can use MySQL's own format() function in the select statement to achieve this:
select format(amount) from your_table
I am trying to save some value prefixed with the currency symbol like in €10. Yet when I manually enter them in the DB the euro sign gets turned now and then in ?. When then I query the line I get sometimes again the question mark with the value and some other times NaN for the full value.
The issue changes if I query the line by using the email field or the unique identifier. Using $ or ® instead of € presents no problems; even ™ is turned to ?, though.
What is strange is that if I try to replace the question mark with the original character, MariaDB complains that there is no change in the line, like if that character were in fact present even if not shown!
I tried restarting MariaDB, just in case, but the problem remained.
I am using UTF32 for encodage and utf32_unicode_ci for collation.
I am testing the thing with Sequel_pro without even touching php not to stack things.
At any rate if I execute the query from a php script and parse the result with JSON I get null for the value.
What could be the issue with those special characters?
Plan A: Store the amount as a string and do not try to get the value out of it. This requires, as already mentioned, "utf8 all the way through".
Plan B: Store only the amount in a numeric field. Either store the 'currency' in another field as 'EUR' or 'USD' or ... Or simply assume that all amounts are Euros. Then put the Euro sign in front of the amount when you print it.
Do not use DOUBLE or FLOAT, you get an undesirable extra rounding. Instead, consider DECIMAL(11,2). That will exactly handle amounts in most countries. (A few countries need 4 decimal places; some can live with 0.)
Do not use utf32; use utf8 (or utf8mb4).
A database is a repository of data, not a formatting tool. Keeping this distinction will help avoid problem like this.
I´ve several dates wich are stored in my database like this: 2016-02-17.
I want them to be displayed like this: 17.02.2016.
For this I use this code in my AppController:
I18n::locale('de-DE');
Time::$defaultLocale = 'de-DE';
Time::setToStringFormat('dd.MM.YYYY');
Type::build('datetime')->useLocaleParser()->setLocaleFormat('dd.MM.YYYY');
But my output always looks like this: 17.02.16.
How do I force the output of the year with 4 characters?
Many thanks in advance. :)
Try using date("d.m.Y", strtotime($yourDateAsStringFromDb)). This will return the date formatted as you describe you want it.
I just tryed using this and it works to display the date as you asked.
bare in mind in this capital letters matter
I use Workbench to query database at work. We have a field which indicates company size and has the following options :
1-9
10-49
50-99
100-499
500+
When I export the results containing this field in Excel(which I use for analysis), 1-9 becomes 9-Jan, when I change the format of the cell to text, it becomes 42013. Similarly, 10-49 becomes Oct-50 and in text - 18537. Is there a way to avoid this?
I know this may seem trivial but I take a download of the results every couple of hours or so, and currently, I use the Replace function in Excel to fix this which is a time cost. Also, adding manual intervention increases the probability of error which I want to minimize. I would ideally like the result to export as 1-9, as it exists in the database, based on which the analytical model is built to take input.
I would appreciate any help or pointers on how to fix this issue.
Thanks!
You are not saying how you are bringing the data into Excel. The simplest method is to bring the column in as "text". You can do this when you are importing the data into Excel, by setting the column type to "text".
Alternatively, when you create the output file, you can prepend the value with a single quote or some other character:
select concat('''', company_size)
select concat('_', company_size)
Appreciate the help! I used to export the results in CSV which caused the problem I think. I exported them in XML and that solved it, the fields appear as they exist in the database. Thanks a lot. The concatenation would work as well!