In Drupal 7 is it possible to specify an input mask for a decimal so that the value is right justified and comma separated after input has been done?
Related
Write one validation rule in contact object in phone field
First requirement is 10 numbers are mandatory & in 10 numbers first two numbers are between 7-9 and remaining between 0-9 ?
For a client I have developed a T-SQL based customer report for calculation the number of working hours per day as as decimal (e.g. 0.5 for 30 min ..). These results are used for a FastReport (Version 3.2.). Currently decimal places are only shown if the calculated number has decimal digits.
Now I want to change the output to always showing 2 decimal digits (e.g. 2.00, 2.50) and if there are more decimal digits I want to show 5 decimal places (e.g. 2.33333).
For the formatstring of the field (showing my calculated working hours) I tried:
%2,2f
which works for the first case. And for 5 places:
%2,5f
But I don't know to dynamically change the format string depending on the number of digits (like hours%0.01 == 0 format string = %2,2f else %2,5f).
I also tried solving the problem on SQL Server 2017 level with:
CASE cdata % 0.01
WHEN 0 THEN CAST(cdata AS DECIMAL(10,2))
ELSE CAST(cdata AS DECIMAL(10,5))
END AS GesHour
and then printing "GesHour" as text. But this doesn't worked either.
It would be very kind if someone could help me.
Currently trying to integrate NgMask below.
Does anyone knows if it supports decimal pattern up to 2 decimal places?
eg. 22.00 or 1893.75
I like to limit entry up to 2 decimal places.
Any regular expression that support this?
http://candreoliveira.github.io/bower_components/angular-mask/examples/index.html#/
This regular expression should work
^\d+\.\d{2}$
This will require at least one digit before the decimal, and 2 digits after.
mask="0*.00" would work if you want to allow numbers with any length before decimal and only two digits after decimal. eg: 23.22, 123452.65 using ng-mask.
I'm trying to use this expression to round money type to two decimal point.
=Format(Fields!ClosingBalance.Value,"#,##0.##")
The problem is I'm getting comma(,) in between, comma I do not want.
Also, 100.00 is showing 100. Here I want 100.00.
Please help
Try changing the format string to #.0,00. That will give you two fixed decimal digits. Your 'comma' is in the language settings. You can create your own culture though and assign it to the renderer.
If you don't want a comma, don't place one in the format string:
=Format(Fields!ClosingBalance.Value,"#.##")
If you want 100.00 instead of 100 the correct Format() is
=Format(Fields!ClosingBalance.Value,"0.00")
In format strings # means show character if non-zero and 0 means show character, zero included
I have a table which contains a field of type numeric(28,10). I would like to display the records with a monospaced font, and a matching number of decimal places so that they line up when right aligned.
Is there any way to figure out the maximum number of decimal places that can be found in a given result set so that I can format accordingly as I display each record?
Edit: sorry, I should have been clearer ... if the result set contains numbers with only 3 decimal places, then all of the numbers should have only 3 decimal places (padded with zeroes).
The monospaced font is entirely a presentation issue...
I don't see your need for right alignment when I test:
CREATE TABLE [dbo].[Table_1](
[num] [numeric](28, 10) NOT NULL
)
INSERT INTO [example].[dbo].[Table_1] VALUES (1.1234567890);
INSERT INTO [example].[dbo].[Table_1] VALUES (1.123456789);
INSERT INTO [example].[dbo].[Table_1] VALUES (1.1234567);
SELECT [num]
FROM [example].[dbo].[Table_1]
...returns:
num
---------------
1.1234567890
1.1234567890
1.1234567000
So the question is--what are you trying to do that isn't giving you the output you desire?
Where do you want to display the results? Query Analyzer? In an application?
You can either
a) format the column to have a
finite number (known in advance) of
digits to the right of the decimal
point, truncating at that position;
this is the typical practice or
b) read through all of the rows in the
resultset to determine the value
with the greatest number of digits
to the right of the decimal point
(casting to string, splitting the
value using the decimal point as
delimiter, and getting the length of
the decimal-fraction string)
If for some reason option a) is unacceptable then you'd have do do b) procedurally, either server-side in a stored procedure or client-side in your client program.