My application exports data into Excel friendly HTML.
With a specific mso-number-format value it is possible to show date or time in a local format. However i know only six such values:
Short Date
Medium Date
Long Date
Short Time
Medium Time
Long Time
.NET offers powerful mechanics of defining localized date format with format specifiers.
Is it possible to map .NET format specifiers in mso-number-format values?
Related
I am trying to convert a datetime string such as 2015-11-01-02.02.38.444000 to Datetime format in Excel. I have tried solutions provided in previous questions, but this particular format was not covered. I am looking to have both date and time in the same cell. Please assist.
It depends how consistent the strings are, but for this particular one you could try
=VALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"-"," ",3),".",":",1),".",":",1))
then use custom formatting to show it as a datetime value with milliseconds
dd/mm/yyyy hh:mm:ss.000
(you may have to change this for your locale).
BTW to make the TIMEVALUE formula in your comment work you would have to change the first two decimal points to colons.
I've imported an Excel spreadsheet into MATLAB which contains a column of timestamps I would like to extract. However, as Excel stores timestamps as numerical data, the imported cells are now in a non-string format such as 0.4479, 0.4480 etc. Is there a quick way to convert all cells to a HH:MM:SS format?
Yep, datestr can handle this pretty easily.
Given:
numericCellData = {0.4479 0.4480}
Use:
datestr(cell2mat(numericCellData),'HH:MM:SS')
What we are doing:
Use the cell2mat function to convert your cell array to a more typical numeric array. This is what the workhorse datestr expects.
The datestr function is meant to perform this exact type of conversion, from numeric time to a string representation.
Your examples were an interesting specific case, where your values probably represented only time (all values were less than 1; you asked for HH:MM:SS format). For the more general case, of converting numeric date-and-time data from Excel to Matlab, you will usually need to adjust for the date offset used:
Matlab date numbers: Are in units of days, usually double precision, and the 0 value represents January 0, 0000. (Think, new years eve in an era when the Roman empire was the dominant political entity in Europe, as represented by the Gregorian calendar which had not yet been developed.)
Excel date numbers: Are also in units of days. However the number 0 represents January 0, 1900. (Or, new years eve, 1899). This is 693961 in the Matlab system, and sometimes you need to make the adjustment.
Select the Column > Right Click >Format Cells >Number Tab> Select Time under Category > Select the Type and click on Ok
Have a large raw data dump and I am trying to format the dates into a consistent format.
As you can see from the screenshot, there are two main formats, one custom mm-dd-yyyy hh:mm AM/PM and mm/dd/yyyy hh:mm:ss. One is stored as general, while the other as a custom value.
I've tried to =left(A2,8), converting via text() and using text to columns, but can't bring the values to a consistent value.
It appears that your Windows regional settings for Short Date are DMY or similar. It is likely your data dump is in MDY format. That is why A2 and A4 are being converted to "real dates" (although incorrectly), and A3 is not since Excel does not know what do with month = 13. You will note that A2 is 1-Dec-2015 and I suspect that in the original data it is 12-Jan-2015.
EDIT: To expand a bit on the explanation. When something that looks like a date or time is entered into an Excel cell, Excel tries to change the result to a date, parsing the input according to the Windows Regional Short Date format. This sometimes has an undesireable outcome. For example, if your Windows Format is MDY but the date is input as DMY, input with days <=12 will be converted incorrectly, and input with days > 12 will be retained as text. This behavior cannot be "turned off" and causes many complaints from those who want to enter data that looks like a date, but is not. (For example, entering an odds ratio as 1-10 or 12:3 will get converted to a date or a time)
Several options
Change the output of the data so as to have the dates in DMY format.
Instead of OPENing the data file, do a Text Import. In later versions of Excel, you will find this on the Data Ribbon ► Get External Data ► From Text. This will open the Text import wizard and allow you to specify the MDY format of the incoming data before Excel transforms it.
After you have done one of the above, the result will be a "real" Excel date or date/time and you can format it how you like.
Write a IF() where if column B specifies "Custom" change format to standard.
For AM, just remove it(replace AM with nothing). For PM add 12 to the hours and replace PM with nothing.
For custom Replace - with / and append :00 to add the seconds to the custom ones too.
Is there universal date format for CSV that can be exported and easily translated in eg. Excel (with different cultures: US, UK, India etc.) ?
My system renders CSV file with US date format but Excel in other cultures can't handle it.
Maybe is possible to convert time from ticks.
I think the answer is No, if only because Excel itself may use either the 1900 or the 1904 date system. Your best bet may be to write a date/time index to .csv (today noon is 42005.5 in the more common 1900 date system) and have the end user format that to suit themselves.
I want a customized format(with milliseconds also) in such a way to handle for a date and time in Microsoft Excel.
Sample date and time:
08.25.2010 00:52:09.359
For understanding of above sample date time, it is 25th August 2010 12 hrs 52mins 9seconds 359 milliseconds(AM).
Please provide a custom Format to handle the above mentioned sample date and time and finally to apply for a column.
In Excel 2003 I use the following for time with fractions of second:
"hh:mm:ss,000"
(note: my decimal point is a "," - German)
so a time entered as 12:13:14,1516 will be displayed as 12:13:14,152
Hope this works for you
Edit 28-Nov-2012
I recently migrated to Excel 2010. Special format using up to 3 zero's after a comma for seconds as described above still works. More than 3 zero's however are not accepted.
I'm not certain what you mean by "not recognizing the dates" but the following custom format would give you the format you're looking for. You'll have to adjust the millisecond separator "." according to your localization, of course.
mm.dd.yyyy hh:mm:ss.000
Applying it to a column is as easy as right clicking the column header, selecting Format Cells, choosing Custom on the left and pasting that format string into the Type box.
If you're trying to enter dates in this format, I don't believe that Excel will support that. I don't know of any option to set the date separators to a "." for Excel. Even setting the date format to use dots under the Regional and Language Options doesn't make Excel recognize that.