How to sort a TEXT Date Column in sharepoint? - sharepoint-2007

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.

Related

Google Sheets – Query for a date returns no values

​​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")&"'")

Value imported can't be changed to a number

I'm using the function importhtml() on my Google Sheets :
=IMPORTHTML("https://fbref.com/fr/comps/13/Statistiques-Ligue-1";"table";3)
The data are imported but some data are displayed "01.08" and the value is a date. The other values are ok if they contains big number like 1.93. How it's possible to change that and have only numbers and not displayed that value as a date ?
I try to change the format of the cell but the value became a number like 44455.
This is a screen of what I have
Just with the importHTML without any cell formatting
After I format the cell as brut text
How can I have the value as a number so to display 1.08 and not 01.08 ( for Google SHeets this is a date )
Thanks a lot in advance
Just add a fourth parameter, which stands for locale.
=IMPORTHTML("https://fbref.com/fr/comps/13/Statistiques-Ligue-1";"table";3;"en_US")
This solved the problem here, since it turns the decimal points into commas, not allowing GS to interpret it as date format.

Last value of a column in Google Sheets

I was trying to use the following function;
=INDEX(D:D,COUNTA(D:D),1),
in order to get the last currency value of a column, but it returns #ERROR!.
The value im trying to extract
As I montly update this spreadsheet, it would make it very convenient if would etract the last value in the column, e.g. the value marked in the image.
Is there a way (in Google Sheets) to find the last non-empty cell in this column, such that when I update the spreadsheet with a new "last value" it would return that value?
The index(counta()) pattern will fail when the data is sparse, i.e., when there are blank values in the column.
The index(match()) pattern will fail when the data contains a value that is not a number.
To find the last non-blank value in column D, regardless of data type, use the +sort(row()) pattern:
=+sort(D1:D; not(isblank(D1:D)) * row(D1:D); false)
The formula uses semicolons as argument separators to make it work in any locale.
If the column has only currency (ie number) values then you can use something like:
=INDEX(D1:D, MATCH(999^99, D1:D))
or try:
=SORTN(D:D; 1;;ROW(D:D)*(D:D<>""); )

How to compare a DATE with a TEXT string in a QUERY function in Google Sheets?

Goal: Return a specific value from a table of data based on a query (kinda like if VLOOKUP provided the option for multiple criteria).
Problem: The data in the source table is a value and I can't change the data source's format. When I run my QUERY function I get #N/A. I know it's due to the data type of the source table data because when I update the format to "plain text" the value works.
Here is my Query:
=QUERY(SessionsData,"select D where B='"&TEXT(Date(YEAR(TODAY()),4,$A143),"yyyy-MM-dd")&"' limit 1",0)
I know the logic works, watch this video for a brief demo.
How can I get this comparison to return results?
Adapted from this answer:
The Query language has two functions to help with date comparisons.
The todate() scalar function will convert spreadsheet dates (like your column B) to query date values. If the value started as a datetime, it returns just the date portion.
The date modifier treats specifically formatted strings as query date values.
Use them like so:
=QUERY(SessionsData,"select D where todate(B)=date '"&TEXT(Date(YEAR(TODAY()),4,$A143),"yyyy-MM-dd")&"' limit 1",0)
^^^^^^^^^ ^^^^

Indexing with a Date field (as a String) in ClientDataSet

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.

Resources