string-formatting

DataGridView comboBoxColumn dateTime format

白昼怎懂夜的黑 提交于 2019-12-24 16:06:17
问题 Winform, dataGridview with a comboBox column. The column datasource is pointing to an Sql table "dateTime" field format. Each row contains a data like 01/01/2014, 01/02/2014, etc.. I am trying to format the comboBox cell in dataGridView to show only month/Year. I tried directly in the designer with a custom format: and with the code: dataGridView1.Columns["Periodo"].DefaultCellStyle.Format = ("{0:M/yyyy}"); and like this dataGridView1.Columns["Periodo"].DefaultCellStyle.Format = "M/yyyy"; and

MDX - Converting Member Value to CDate

若如初见. 提交于 2019-12-24 14:50:13
问题 I need to convert a member value from this format dd.MM.yyyy into a CDate. This was my trial: cdate(format([Date].[Date].CURRENTMEMBER.MEMBER_VALUE, "dd.MM.yyyy")) Source: http://www.datazen.com/blogs/post/working-with-dates-in-datazen-3-0 However, I get a type mismatch error, because the format function ist not working properly. I'm using a Microsoft Analysis Server. Do someone know a solution for this issue? 回答1: You need to create a measure when to extract the date. Here is a possible

Substring a bound String

旧时模样 提交于 2019-12-24 14:23:50
问题 What I want is to bind a string to a textblock or datatrigger (basically some WPF object) and take a part of the string. This string will be delimited. So, for example, I have this string: String values = "value1|value2"; And I have two controls - txtBlock1 and txtBlock2 . In txtBlock1 I would like to set the Text property like Text={Binding values} . In txtBlock2 I would like to set the Text property like Text={Binding values} . Obviously this will display the same string so I need some sort

Using Javas System.out.format to align integer values

↘锁芯ラ 提交于 2019-12-24 10:15:40
问题 I am trying to produce right aligned numbers looking a bit like this: 12345 2345 but I clearly does not understand the syntax. I have been trying to follow these instructions. and Come up with the following attempt (it is integers so d and I want width 7 and 0 decimals): public class test { public static void main( String[] args ) { System.out.format("%7.0d%n", 12345); System.out.format("%7.0d%n", 2345); } } but no matter what I do I seem to end up with IllegalFormatPrecisionException . Is

Escape quotes in string interpolation s“ALTER TABLE ${keyspace}.\”${tableName}\“”

情到浓时终转凉″ 提交于 2019-12-24 09:58:52
问题 In Scala, while querying Cassandra, this string interpolation s"ALTER TABLE ${keyspace}.\"${tableName}\" " gives me this error: error: value $ is not a member of String [INFO] val query:String=s"ALTER TABLE ${keyspace}.\"${tableName}\" ADD $colName $dataTypeAsString;" What am I doing wrong? 回答1: The \" does not work inside string interpolations. Try using strings delimited by triple quotes: s"""ALTER TABLE ${keyspace}."${tableName}" """ or escape the inner double quotes by additional ${...} :

Display format string, int to percent

穿精又带淫゛_ 提交于 2019-12-24 09:17:32
问题 I have some integer values (between 1 and 100) and I want to use them in a progress bar, that has a DisplayFormatString property. I also want to have the percent symbol '%' in the output string. The problem is that by using the symbol, it automatically multiplies my value with 100, and it shows my values like 3300% when I wanted them 33%. How may I overcome this? DisplayFormatString="0%" 回答1: Try using 0'%' as the DisplayFormatString , (percentage in single quotes) this should help in

Getting Wrong DateTime Format

拈花ヽ惹草 提交于 2019-12-24 08:56:59
问题 I have this: var dateString = string.Format("{0:dd/MM/yyyy}", date); But dateString is 13.05.2011 instead of 13/05/2011. Can you help me? 回答1: You could use DateTime.ToString with CultureInfo.InvariantCulture instead: var dateString = date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture); The reason why / is replaced with . is that / is a custom format specifier The "/" custom format specifier represents the date separator, which is used to differentiate years, months, and days. The

Double.ToString for formatting

陌路散爱 提交于 2019-12-24 05:54:42
问题 I need to format a number with a specific format. I don't want to decide on the format with the regional settings of the computer so I'm trying: string s = "219171" string result = Convert.ToDouble(s).ToString("0,0.0") //219,171.0 string result = Convert.ToDouble(s).ToString("0.0,0") //219171.00 I want to display it as 219.171,00 Thank you 回答1: Create a custom NumberFormatInfo instance and pass that in when calling ToString(). NumberFormatInfo nfi = new NumberFormatInfo(); nfi

How to prevent PyMySQL from escaping identifier names?

余生长醉 提交于 2019-12-24 03:42:33
问题 I am utilizing PyMySQL with Python 2.7 and try to execute the following statement: 'INSERT INTO %s (%s, %s) VALUES (%s, %s) ON DUPLICATE KEY UPDATE %s = %s' With the following parameters: ('artikel', 'REC_ID', 'odoo_created', u'48094', '2014-12-23 10:00:00', 'odoo_modified', '2014-12-23 10:00:00') Always resulting in: {ProgrammingError}(1064, u"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''artikel' ('REC

How to prevent PyMySQL from escaping identifier names?

瘦欲@ 提交于 2019-12-24 03:41:18
问题 I am utilizing PyMySQL with Python 2.7 and try to execute the following statement: 'INSERT INTO %s (%s, %s) VALUES (%s, %s) ON DUPLICATE KEY UPDATE %s = %s' With the following parameters: ('artikel', 'REC_ID', 'odoo_created', u'48094', '2014-12-23 10:00:00', 'odoo_modified', '2014-12-23 10:00:00') Always resulting in: {ProgrammingError}(1064, u"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''artikel' ('REC