For view purposes I am formatting the date values in my grid and that seems to be fine.
The problem is my column is also sortable and my custom date formatting is messing up the sorting. If I sort by real values from database, the sorting is fine but then I lose the ability of custom formatting the date for view purposes. So I wanted to see if there is a way to tell it format it like this but sort it some other way?
Here is how I format:
obj.Item.CustomFormattedDate = kendo.toString(kendo.parseDate(obj.Item.RealDbDate, 'yyyy-MM-ddTHH:mm:ss'), 'MM/dd/yyyy hh:mm tt');
and then in my column definitions I setting my column to that field CustomFormattedDate which is good for viewing but BAD for sorting. If I switch my field to be the actual RealDbDate values, then sorting becomes good but viewing becomes bad!
I'm doing exactly what you're looking for. I'm using the ASP.NET Core wrappers for Kendo and set up the column like this:
columns.Bound(p => p.ShipDate).Format("{0:g}");
Ship Date in the model is a DateTime, the sorting works, but then I can make that format string any of those listed here https://docs.telerik.com/kendo-ui/globalization/intl/dateformatting
Related
I am using PowerpointWriter to populate a ppt table. I have currency and date columns that need to be formatted (not with colors/fonts/etc). For example, the date column needs to be the date only, not the time.
How do I do this?
Thanks,
Cheri
PowerPointWriter does not support that kind of formatting at the moment. You should consider formatting your data in your application before binding the data to the PowerPoint file using PowerPointWriter..
I use Google Sheets to keep a list of applications I am doing. In each row there is a date field. I want to sort by date now. The first row is frozen using View - Freeze - 1 row. When I select the whole table, press Data - Sort range... and then check Data has header row the sheet is sorted. But not by date but by string. The format of the cells is date. Is only string sorting possible? If yes, I would have to reformat the whole document to dates like 2017-01-11, correct?
The solution was to replace the . by /. Seems as if the common german format using . is not yet supported. Make sure the date is recognized as date. If the cell is right-aligned it worked, if not it did not work.
I learned that you can create a custom date format using the ..
Now the date is entered 10/01/2017 but displayed 10.01.2017. Just the way I wanted.
I am editing a Webi report using SAP Business Objects BI4.
I have a report with a table in which I display a date formatted like this :
=FormatDate([Sales Date];"dd-MMM-yyyy")
Originally, Sales Date dimension has the format "mm/dd/yyyy".
I want to sort my table by this formatted date dimension in ascending order, so I just select my table > right click > select Sort and then I select the =FormatDate([Sales Date];"dd-MMM-yyyy") in ascending order.
My problem is that, the sorting behavior is incorrect as the result is as follows:
Sales Date
----------
01-AUG-2006
----------
01-JUL-2010
----------
02-FEB-2006
----------
03-AUG-2005
As you can see above, it seems that the sorting is only done by the "day" value and it completely ignores the "month" and "year".
My object is correctly defined as "Date" in the universe.
and the sorting is correctly done when I don't use the formatting "dd-MMM-yyyy" and keep the original format of Sales Date.
Any suggestions please?
Thanks!
The return data type of the FormatDate is a string. This is why the sorting will be out of order as it will sort the string value instead of the date value.
You have two options:
Format the date using a (custom) date format (In the Formatting section when you have the document in Edit mode). You'll need to use the RIA (Java applet) in order to define your own custom date format. Alternatively you can use one of the formats available. This will not change the data type but only the presentation, thus the sorting should be fine.
If you still want to use the FormatDate option, you could add the [Sales Date] in a second column, use it to sort your data and then hide the column.
I'm stuck with sorting and showing the correct date in Xpages.
It is saved in format "dd.MM.yyyy" and it's a string.
Now why it's a string and formated that way, is because my boss has special wishes. And when I want to sort it from the newest date to older it does something like this:
26.05.2015
24.06.2014
22.04.2015
21.04.2015
20.03.2014
It starts sorting by day.
Is there a way to make it sort it like it should?
I see that i can write a Computed value to Sort column in view column header for date. But i don't know how to even start.
Change the underlying Notes view to get your date column into right order.
Convert the date strings to real date values in views column formula. Assuming your field is called DateText then your formula would be
#Date(#ToNumber(#Right(DateText; 4));
#ToNumber(#Middle(DateText; 3; 2));
#ToNumber(#Left(DateText; 2)))
It would be easier to use just #ToTime(DateText) but this can fail depending on server's local settings. Your date string format would work for a server with German locale settings but not for US. That's why is my suggested solution "safer".
If the date time value doesn't solve your problem and you do not transform your date via #Text (as mentioned in the comments) then create another (hidden) column BEFORE your column that should be displayed. Make this a true date (from your item), sort it and unsort the column to display.
Otherwise use this formula in the newly created sorted column:
#Text(#Year(yourDate))+"-"+#Right("00"+#Text(#Month(yourDate));2)+"-"+#Right("00"+#Text(#Day(yourDate));2)
I had a need to output TCURR table into ALV grid. All went fine but when user sorts table by "valid from" date (GDATU) strange things happened.
Sorting in ascending order behaves as sorting in descending order and vice versa. This is so because field GDATU contains date in inverted format and has domain GDATU_INV with the conversion routine INVDT which converts date on the fly. ALV grid shows the date correctly but sorting is done by inverted dates.
I solved it like this:
I declared table structure similar to TCURR and replaced GDATU_INV domain with simple DATUM.
I converted inverted dates into usual ones
I filled my table with the converted dates
After generating field catalog through FM LVC_FIELDCATALOG_MERGE according to TCURR structure I write to
CONVEXIT,
REF_TABLE,
DATATYPE,
DOMNAME
fields of the GDATU line values
'',
'',
'DATS',
'DATUM' respectively.
Is there more efficient and simple solution to this problem?
You should be able to use your new structure in LVC_FIELDCATALOG_MERGE, in stead of using TCURR which would mean that you don't have to overwrite the settings in the field catalog after the fact. But that's a pretty minor thing.
I don't think you had any choice but to use a structure with a data element that behaves the way you need it to.
Do look into the Simple ALV classes, though. (CL_SALV*) They are well documented and much easier to use than then now out-of-date ALV function modules. (Particularly generating the field catalog is a lot less hassle).