Writing mm-aaaa in excel without it changing it by a date - excel

I must write mm-aaaa (06-2014 for example) in an Excel sheet, but each time I do so, Excel automatically changes my cell format to "personalised" and select a date format.
Writing the value and pressing enter changes the format to custom; changing the format back to General change the date to 41780, which is no good either.
I absolutely need to keep the "General" format and the date to be written as mm-aaaa because the file is then going to be read by a python script which I cannot change. How can I achieve this?

Special pasting as text didn't work.
However setting the cell format as text, writing in it then changing it back to standart worked

Related

Is there a way to ensure that excel doesn't truncate my date-time data?

I work with timeseries data and often save and import files into R from csvs in excel. I've noticed that excel does not like date-times in the format "m/d/yyyy h:mm:ss". I can go into format cells and enter a custom formula to force it to display the whole date but if I open a file, it will automatically format the date-time to m/d/yyyy h:mm and if I then save the file accidentally, close it and reopen it. The second information of m/d/yyyy h:mm:ss is lost. Is there any way to prevent this? Other than splitting date-times into multiple columns and having lots of back up copies?
Thanks!

Heroku Dataclip, How to export date column into XLS

When a column contains a Date field, the dataclip displays it. When the "Export/Share" link is clicked and XLS selected, the resulting Date column is treated like a TEXT column in XLS.
Changing the Format in XLS does not seem to have an effect on it.
Is there a proper format for export that will make it into a Date cell?
I have tried 'MM-DD-YYY', 'MM/DD/YYY' and left it as default display (which puts the date and time in the column).
None of these are "dates" in XLS.
Thanks
I have done some tests and I think dates are exported as YYYY-MM-DD.
I really don't have Excel installed on this computer right now, but I downloaded an xls file from dataclips and imported it on Googlesheets. Dates were correct without any conversion needed.

Excel sheets In Selenium WebDriver

I have to read data from excel sheets to forms I automate using Webdriver2 and Testng but most of the time i am faced with the problem that the entered data in excel is not correctly put into forms while running the script.for e.g-
if I enter 2015 in excel( for an year field) it puts 1900 in form ,If I change the format of cell to text in excel, it works fine but then some other field is incorrectly entered.Like I had a scenario where the date field in form had format dd.mm.yyyy and the time had format hh:mm. So, it was entering correct values from excel( even though my excel lib code had format like dd/mm/yyyy) but for time field if i enter 31:12(any value greater than 24) it puts something else in form like 52:0.
I want to know, is there a way to format excel in such a way that it puts whatever data i put in cell regardless of format change.
I have tried changing the format , using regular expressions( works fine) and implemented suggestions from Web but sometimes nothing works.
Thanks in advance

Perl - Reformat a column in Excel

Using some combination of Win32::OLE, ParseExcel, WriteExcel...I want to be able to change the formatting of all of the cells in a column (or multiple columns, based on a condition) to be a custom date format, such as "yyyy-mm-dd h".
I have been able to use Win32::OLE to do a find and replace on an Excel file that I have open, but I am not sure the best way to reformat an entire column of cells. I imagine it will be something along the lines of parsing the file with ParseExcel, and using WriteExcel to overwrite the file after changing the format somehow.
Any advice would be greatly appreciated, cheers!
Don't overwrite, copy to a new name (then you can compare, and the process is reversable).
You would essentially copy all the cells, modifying only the ones you need to format change.
Excel Format Info - many examples for formatting time

Saving to CSV in Excel loses regional date format

I have a .xls I need to convert to .csv
The file contains some date columns. The format on the date is "*14/03/2001" which, according to Excel means the date responds to regional date and time settings specified for the OS.
Opening in Excel you see:
20/01/2013
01/05/2013
Save as... CSV
Open in notepad:
01/20/2013
05/01/2013
I have temporarily fixed by setting date formats to "14/03/2001" (no *) but even some other custom formats with no *, like "d/mm/yyyy h:mm" get mangled when saved to CSV.
Although keeping this in mind http://xkcd.com/1179/
In the end I decided to use the format YYYYMMDD in all CSV files, which doesn't convert to date in Excel, but can be read by all our applications correctly.
You can save your desired date format from Excel to .csv by following this procedure, hopefully an excel guru can refine further and reduce the number of steps:
Create a new column DATE_TMP and set it equal to the =TEXT( oldcolumn, "date-format-arg" ) formula.
For example, in your example if your dates were in column A the value in row 1 for this new column would be:
=TEXT( A1, "dd/mm/yyyy" )
Insert a blank column DATE_NEW next to your existing date column.
Paste the contents of DATE_TMP into DATE_NEW using the "paste as value" option.
Remove DATE_TMP and your existing date column, rename DATE_NEW to your old date column.
Save as csv.
Change the date and time settings for your computer in the "short date" format under calendar settings. This will change the format for everything yyyy-mm-dd or however you want it to display; but remember it will look like that even for files saved on your computer.
At least it works.
You need to do a lot more work than 1. click export 2. Open file.
I think that when the Excel CSV documentation talks about OS and regional settings being interpreted, that means that Excel will do that when it opens the file (which is in their "special" csv format). See this article, "Excel formatting and features are not transferred to other file formats"
Also, Excel is actually storing a number, and converting to a date string only for display. When it exports to CSV, it is converting it to a different date string. If you want that date string to be non-default, you will need to convert your Excel cells to strings before performing your export.
Alternately, you could convert your dates to the number value that Excel is saving. Since that is a time code, it actually will obey OS and regional settings, assuming you import it properly. Notepad will only show you the 10-digit number, though.
If you use a Custom format, rather than one of the pre-selected Date formats, the export to CSV will keep your selected format. Otherwise it defaults back to the US format
Place an apostrophe in front of the date and it should export in the correct format. Just found it out for myself, I found this thread searching for an answer.
A not so scalable fix that I used for this is to copy the data to a plain text editor, convert the cells to text and then copy the data back to the spreadsheet.
Change the date range to "General" format and save the workbook once, and change them back to date format (eg, numberformat = "d/m/yyyy") before save & close the book. savechanges parameter is true.
You can send your date to excel not like the "date" but like just a "string" with empty space at the start and end of the string.
Your problem is happening due to excel see your '11/02/2023' like a date, but you can hack it and change this date to a simple string like ' 11/02/2023 '.
Old: '11/02/2023'
New (solution): ' 11/02/2023 '

Resources