I have a template, where I have a table with column which I want to format as currency (2 decimal places). I'm using Velocity and NumberTool, which is putted in context.
I tried to use <<$number.format("currency", $My_data)>> in template, but as result I got empty column.
Is there some possibility to format list field in table without writing e.g. new foreach? Is some function which can be use in tempate to format field in one column?
Regards
I resolve it by myself.
I must just override VelocityTemplateEngine and Formatter to recognize phrases like <<$numberTool.format($My_data)>>, becouse default formatter was looking for field name after first '$'.
Related
I changed the Field Type from string to integer from there the value I am getting is with commas in between the value. Example mobile number(9748376253) destination field as (9,748,376,253), this is because the default number format in opensearch will take as 1000's place so it divides in such a way. So by following the below stackoverflow i changed accordingly(Kibana unwanted thousand-seperator) as type number and changed the format to 00.[000] from 0,0.[000]. but changes are not effected. Will it take time to effect or any other issue ? Is there any option to change this format number setting only for one particular index ?
I'm trying to add a field on my form that suggests different ID's in the database. I'm getting the error suggest_field.ID does not support the startsWith function. Is there any way to change this so that I can use the Suggest box with numbers
Since your IDs are integers and not strings they do not have a startsWith function. You can use (#datasource.items..Id).map(String) as your suggest box options and then autocomplete would work. Just be careful with value bindings as the types will not match - you may have to ditch bindings for value and use the onAttach and onValueChange events to convert the type to/from an integer and then set your datasource item's ID value (use parseInt(string) to convert a string to a number type and use number.toString() to convert a number to a string).
I'm brand new to Power BI and I'm not sure if I'm doing something wrong, but I would expect a "date/time" field would have special options for filtering. However, the filter actually lists a dropdown of all values ("2015-09-24 12:00:01", "2015-09-24 12:00:02", "2015-09-24 12:00:03", etc).
How can I filter by "last year" or "last 7 days"? Am I missing something simple?
I have tried in the web interface and Desktop.
You need to set the field's data type to Date/Time. If you're seeing strings, the most common issue is that in the query the field is defined as type "any", which gets interpreted as a string. So just go to the query window, change the data type for the affected columns, and see what happens. One little hint, is that usually after you use a function or transform (especially Add Column!) the resulting column will have the "any" data type. So double check and set the data type you really want.
I have been reading all about converting TEXT fields into date formats and ways to use Python to create date objects but my question remains.
My table has a dateTime column that is specified as TEXT, I would like to build a constraint that forces input to be in dateTime format, but as SQLite doesn't do dates (as I would like) I haven't worked out how to do it.
My current ideas: 1. Limit number of characters
2. Set separate attributes for day, month and year and constrain their domains
3. It is silly to do this on the database side just do it in the user interface
I would appreciate your opinions on these or other options.
Thanks :)
I've been trying to solve the same issue and the method I came up with was to use the date/time functions to parse the value and check that it hasn't changed. Essentially the following:
CREATE TABLE dts_test (
dts TEXT CHECK (dts IS datetime(dts))
);
If the default format is not what you want you can use the strftime or similar to design whatever format you want, but it must be something that the built-in date and time functions can parse.
I have a table that contains three columns.
"UserId" type-nvarchar
"PostAuthorId" type-nvarchar
"Post" type-text
This table will contain "wall" posts like in facebook for each user's page. I am going to use a gridview on each user's page to display the posts. The issue is I want to display them with the latest(most current) post being first and the earliest post being last.
I have never used autoincrement before and I am not sure if that is the answer. If it is, I do not know how to use it. I thought about adding a date posted column and then ordering by date.
If I end up using the date column, I could also display the date on the post. Is there a way to convert the date to a readable format?
What is the best way of implementing this type of ordering?
If you use AutoIcrement the first record will start with 1 and each record will increment from there. (default setting)
If you want to sort them by newest first do an ORDER BY ID DESC
I would suggest making a column called wallPostID then setting that to AutoIncrement and also your Primary Key
Date Formating:
If you are displaying this data in a gridView
Go to Edit Columns on your grid view
CLick on the Date field under "Selected Fields" on the bottom left
Under "BoundField properties" on the right Go to Data -> DataFormatString
{0:d} will display as 1/1/2010
This site has more info in string formatting
http://msdn.microsoft.com/en-us/library/fht0f5be.aspx
A datetime column would definitely work for something like this. Assuming you are using MS-SQL, you can also attach a default value to the column using a built-in function like GETDATE(). That way, you only have to input the data that matters and the database will take care of adding the datetime column.
For converting a datetime to a readable format try:
DateTime postDate;
string value = postDate.ToShortDateString();
You should always use an ID field that auto increments. Can also be used as your PK
I would suggest the DateTime field rather than the autoincrement simply because it will not only serve as an effective Sort field, it also preserves information that you may well want to display. If you want the most recent first you'll sort using the Date and a "DESC" modifier:
Select ... Order By [Date] DESC;
When you retrieve the data, you can retrieve it as a DateTime and modify it using C#. You can use "ToShortDateString()" as suggested by mdresser if you just wish to show the date or ToString("...") if you wish to show the time as well. You can also use SQL to convert it into a string before retrieving it:
convert(Varchar(10), #mydatetime, 101)
If you look in MSDN you'll see the various conversion codes (101 is the code used above) that can be used to translate the date in various ways.
UPDATE: You may want to use an autoincrementing field for your application for reasons other than your expressed need to sort wall entries. They are easy to use - just mark the field as an Identity if using SQL Server (other DBs are similar). As far as using them in your program, just think of the field as an Int field that you never have to set.
Now, why would you use a auto-incrementing field? Perhaps the most straightforward reason is so that they give you have an easy way to identify each record. For example, if you permit people to alter or delete their wall entries, the auto-incrementing field is ideal as it gives you a way to easily look up each record (each record will be assigned its own, unique value). You might put an "x" next to the record like StackOverflow does and make it a call back with the UID (auto-increment) value. Note that you should set up your primary key on the UID field if you'll be doing this.
Now, if you find them useful for this reason then you could also sort by the UID. I would still store the date so that you can provide Date and Time feedback as to when an entry was made on the wall but this would no longer be your indexed or sorted field.