Excel formatting my dates when I don't want it to? - excel-interop

I'm using excel interop to build reports. I have the string "April 8, 2013" as a string and I'm assigning it to a cell as such (where oSheet is an Excel._Worksheet and it's VB.Net):
oSheet.Cells(5, 2) = dateStr;
Nothing is modifying the NumberFormat or any other properties for that particular cell but what is being displayed when I open the output xlsx file is "8-Apr-13".
How can I force excel to just display the string without any additional formatting that might change the text?

To force Excel to treat a date, or any non-textual data, as text, and thus not changing it's format automatically, you can use either of the following two methods:
Precede the date with a single quote, e.g. '08/01/2013
Set the NumberFormat of the range to Text with range.NumberFormat = "#";

Related

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.

How to change MM/DD/YYYY to DD/MM/YYYY

I have imported a CSV file to the spreadsheet that includes columns with Dates and timestamp (Columns D,E,K,L) and I'm currently facing 2 problems with these columns.
Some rows are formatted as text/string and I can't seem to change it to date format. I tried manually changing it via format>number>datetime but it remains the same.
the format of the date is being read incorrectly by spreadsheet. For example, 5/11/2018 is being read as May 11, 2019 but if you try to review the spreadsheet, it should be read as November 5, 2018. I tried playing with the format and spreadsheet settings to no avail.
Spreadsheet Sample
I'd appreciate any inputs.
UPDATE
For Column D & E, I have already converted all rows to Date but the problem persists where in some rows are being read as DD/MM/YYYY and some rows MM/DD/YYYY. This creates date discrepancy when I try to make data visualization using these data:(
I am unable to convert all rows in Column L to date format. Some rows are still being read as text/string.
if you have a spare column you can use this formula to correct it:
=DATE(RIGHT(A1; 4); MID(A1; 4; 2); LEFT(A1; 2))
also, you can try to change locale settings in your spreadsheet because it looks like that your spreadsheet uses mm/dd/yyyy format as default. eg. you can try for example Czech locale where default is dd/mm/yyyy
To format custom dates in Google Sheets:
Highlight the column to be formatted.
Navigate the app's menu path:
Format >> Number >> More Formats >> More data and time formats
Put your cursor in the top field of the popup and edit as necessary...
Delete parts you don't want.
Add parts you do want (but make sure you're adding them left-to-right).
Put character(s) between the fields as separators.
Format each part via its dropdown list of options.
Click the "Apply" button, and you're done.

Date converted to plain text in google spreadsheet

I use importdata() to grab a legacy file and use it in a spreadsheet.
This file contains date's in the yyyymmdd format (i.e. 20150520)
I wish to filter out dates what contain a certain date, so when I type in a cell "20150520") it work fine, but when I calculate or copy the date from another cell, the filter don't work anymore
=filter(import!A1:E77;import!C1:C77=G31)
G31 ="20150520" works fine
G31 =TODAY() #N/A
G31 =text(TODAY();"yyyymmdd") #N/A
How can I compose cell 31, in a way the filter will work
(sheet 'import' has imported data with dates like 20150520(
Your legacy file may be formatting it as a number, in which case you need to change your G31 to a number as well. Try
=Int(Text(Today(),"yyyymmdd"))

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.

How to sort a TEXT Date Column in sharepoint?

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.

Resources