on Delphi XE2,
I have a ClientDataSet which have many fields as Name, ...
It have a field named Date, as value type String. Containing a Date (dd/mm/yyyy)
I want to print content of ClientDataSet, using FastReport.
I want before to sort content ascending according to the Date field. I'm using index.
But when doing this, sorting does only sorts fields according to the content of the Date string before the "/".
form example dates like : 12/11/2012, 15/10/2012, 01/12/2012 are sorting like this : 01/12/2012 - 12/11/2012 - 15/10/2012.
ny idea how doing this correctly ?!
The sorting is correct! As you have a string field, the sorting is made like strings are sorted i.e. from left to right. If you want it sorted by Date you need either a date field or sort the string representation like yyyy/mm/dd.
You have some options:
Bring the field as a DateTime field. You would have to change the original SQL to that.
Do what Marjan suggested, bringing that string field formatted on an ISO-like style (which allows for the field to be ordered cronologically when string sorting is aplied) and creating an calculated field for user-display formatting.
Creating a new field on the TDatasetProvider's OnGetRecords event and populating it as a Date field.
Similar as above but creating a string field with the date formatted in ISO-Like style.
I personally suggest the first approach if possible.
Related
I'm trying to filter a list from another sheet by the dates of the entries and simply doesn't work:
=QUERY(Import!A:Z;"select A,T where T >= date '2021-08-27'";0)
When I remove the date part it works fine, as expexted for filtering by text. I need the ability to sort by exact dates though, because I would like to add some more complex filters. When I set the last part of the function to a 0 instead of a 1 it shows only the first entry.
The source column is set to the correct date format. The data is pulled from another document using the IMPORTRANGE() function (I don't seee how this should make any difference though).
I feel like I'm misssing something simple here and would be glad if someone can point me in the right direction!
Check your date column if all cells are formatted as date. I had missing values as "='---" and the query filtering by date returned nothing. Changing the missing values to "=NA()" did the job.
Try this:
=QUERY(Import!A:Z;"select A,T where T >= date '"&TEXT("2021-08-27";"yyyy-mm-dd")&"'")
=filter(query(Vendors!$A$3:$M,"select A,B,C,D,E,F,G,H,I,J,K,L,M",1),Vendors!$L$3:$L = "Invited",Vendors!$I$3:$I - Vendors!$G$3:$G <=$F$6)
I have the above formula that will query and return the results. However in all date columns I get a random number string instead of the date being referenced.
Query Results
I tried enabling data validation in one column to fromat as date.
Any advice on how to get the query to return the date instead of this number string? All of the other columns return text and numbers correctly.
Those are date numbers. Format those columns as dates from the sheet menu.
The query (as you specify) would return the date instead of the number string it you appropriately added a format clause. Exactly what that would be cannot be deduced from the little information you have provided.
I have a string column in which I am storing a value like this "2015-11-04 09:09:00 PM". For a particular reason I have not considered it as a datetime column. Now I just want to order the records according to its ascending order. When I do a simple sort using order, I am not getting the expected output.
Help!
try this:
Model.all.sort_by{|m| m.field_name.to_datetime}
I have Firebird table with field 'ABC' of Time type. I use TMaskedEdit to populate it with mask: !90:00;1;_
It works fine when populating the field with values but does not work properly when displaying values from the field.
I use:
editABC.Text := DateTimeToStr(fieldbyname('ABC').AsDateTime);
The problem I get is that time like for example: 14:48 is displayed as 14:00
Question: how can I display value of field of type Time properly in TMaskedEdit properly?
I have data :- 31-May-07
Its in a calculated column of the list. The method I used to get it :- =IF(FDate="","",TEXT(FDate,"dd-mmm-yy")) {FDate is a DateTime type of column. The returned value is stored in a "Single Line of Text" column type.}
I am now unable to sort that column as its Text now and sorting is done on basis of strings.
I need to sort this column on basis of Date.
Any help ?
Thanks!!
I'm not familiar with Sharepoint but this looks like a pure Excel question. I presume you don't really want to convert the date into text. Let it be a date and just change the cell format.