decimal

convert time to decimal in SQL server 2012

陌路散爱 提交于 2020-01-25 14:37:51
问题 i have a table in sql server 2012, with one of its column having the following data in time datatype, How would you convert 00:45:00 to 0.45 or 01:45:00 to 1.45 ? please help. 回答1: From the question, it seems you only want to remove the ':' with '.'. If so, it can be achieved in many ways in sql server 2012. One example is below. If your column is 'Datetime', use this: SELECT REPLACE(LEFT(CAST(DatetimeCol AS TIME),5),':',',') FROM Tbl Else if it just 'Time' then remove the casting. 回答2: You

convert time to decimal in SQL server 2012

雨燕双飞 提交于 2020-01-25 14:36:44
问题 i have a table in sql server 2012, with one of its column having the following data in time datatype, How would you convert 00:45:00 to 0.45 or 01:45:00 to 1.45 ? please help. 回答1: From the question, it seems you only want to remove the ':' with '.'. If so, it can be achieved in many ways in sql server 2012. One example is below. If your column is 'Datetime', use this: SELECT REPLACE(LEFT(CAST(DatetimeCol AS TIME),5),':',',') FROM Tbl Else if it just 'Time' then remove the casting. 回答2: You

MATLAB: ??? Undefined function or method 'sprint' for input arguments of type 'char'

霸气de小男生 提交于 2020-01-25 09:46:07
问题 I´m trying to show 16 decimal place of a result. The code I put is this clear x; x = 0.245; 1-x+1/2*x.^2-1/6*x.^3+1/24*x.^4 sprint('%0.16f', ans) Matlab give me this answer ans = 0.7827 ??? Undefined function or method 'sprint' for input arguments of type 'char'. I have two question: What happen? I think I used it before and I had no problems with 'sprintf' for show a result with several decimal places. What can I do to show more decimal places? Thank you! 回答1: sprintf formats data into a

Formatting Decimal Number

最后都变了- 提交于 2020-01-25 06:13:47
问题 I am formatting a decimal number and I have the following criteria to format it: Number should be at most two decimal places ( 10.1234=>10.12 ) If there is only one digit after decimal then it will ends up with an extra 0 ( 10.5=>10.50 ) Thousand separator will be comma ( 12345.2345 => 12,345.23 ) I have written following logic: double x = Double.parseDouble(value.toString()); String dec = x % 1 == 0 ? new java.text.DecimalFormat("###,###.##").format(x) : new java.text.DecimalFormat("###,###

Formatting Decimal Number

让人想犯罪 __ 提交于 2020-01-25 06:13:24
问题 I am formatting a decimal number and I have the following criteria to format it: Number should be at most two decimal places ( 10.1234=>10.12 ) If there is only one digit after decimal then it will ends up with an extra 0 ( 10.5=>10.50 ) Thousand separator will be comma ( 12345.2345 => 12,345.23 ) I have written following logic: double x = Double.parseDouble(value.toString()); String dec = x % 1 == 0 ? new java.text.DecimalFormat("###,###.##").format(x) : new java.text.DecimalFormat("###,###

Always Show 4 Decimal Places

无人久伴 提交于 2020-01-24 12:42:07
问题 Is it possible to force a cell to always show 4 decimal places using xlwt? Regardless of the number actually present after the decimal place. I have done some searching and I can find a string to always reduce to 2 decimal places, but I need certain cells on my sheet to show 4. 回答1: Use xlwt styles. Here's a simple example: import xlwt book = xlwt.Workbook() sheet = book.add_sheet("test") decimal_style = xlwt.XFStyle() decimal_style.num_format_str = '0.0000' sheet.write(0, 0, 1.23456789,

Always Show 4 Decimal Places

烈酒焚心 提交于 2020-01-24 12:42:05
问题 Is it possible to force a cell to always show 4 decimal places using xlwt? Regardless of the number actually present after the decimal place. I have done some searching and I can find a string to always reduce to 2 decimal places, but I need certain cells on my sheet to show 4. 回答1: Use xlwt styles. Here's a simple example: import xlwt book = xlwt.Workbook() sheet = book.add_sheet("test") decimal_style = xlwt.XFStyle() decimal_style.num_format_str = '0.0000' sheet.write(0, 0, 1.23456789,

OverflowException when converting SqlDecimal to Decimal

旧时模样 提交于 2020-01-24 08:54:06
问题 In our real application we get an OverflowException when trying to convert SqlDecimal value of 99 to System.Decimal. The exception is thrown because SqlDecimal's precision is higher than System.Decimal's precision. Here is a test that reproduces the issue: [Test] public void SqlDecimalToDecimalOverflowTest() { // in our real application d1 & d2 are loaded from a database; both are declared as DECIMAL(28, 5) // for test purposes I recreate identical SqlDecimal objects here: var d1 = new

Faster alternative to decimal.Parse

梦想的初衷 提交于 2020-01-24 02:21:16
问题 I noticed decimal.Parse(number, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture) is about 100% slower than custom decimal parse method based on Jeffrey Sax's code from Faster alternative to Convert.ToDouble public static decimal ParseDecimal(string input) { bool negative = false; long n = 0; int len = input.Length; int decimalPosition = len; if (len != 0) { int start = 0; if (input[0] == '-') { negative = true; start = 1; } for (int k = start; k < len; k++) { char c = input[k];

How to make a REGEX statement that will allow interpretation of EU and US decimal notations

北城以北 提交于 2020-01-21 19:00:41
问题 I have been working on a tough question and gotten a lot of help from programmers and developers on this site. Many thanks to those who contribute. You are invaluable. Using Javascript and HTML. I am a newbie. The current condition of my problem is this... I am attempting to develop a metric to english conversion website that takes a numeric value in a HTML textbox (no form): I want the user to have multiple ways of entering the data into the conversion tool as it will be used internationally