Change the Excel date input format? - excel

I've been struggling with Excel (2016) date formats. I know how to change display formats for dates and cells but the problem I have is the input format for dates. If I input a date as "DD.MM" or "DD.MM.YYYY" it does recognize it as a date but if I input the date as "DD.MM." (with the second dot after the month), Excel does not recognize it as a date anymore. The column in question is formatted as short date.
Is there anything that can be done or is this by-design? If so, it seems really strange as at least in my country it's the official way to write the date containing that second dot after the month number when there is no year included in the date.
I've been searching and Googling for solution but couldn't find anything on this really. I appreciate all comments and help regarding this question!
SUMMARY/TL;DR:
Excel version is 2016, country is Finland and language is finnish
Excel accepts/recognizes these as dates: 12.5 or 30.8
Excel does NOT accept/recognize these as dates: 12.5. or 30.8.
The column in question is formatted as short date
The dot after the month seems to be screwing things up
Why is this happening? Can anything be done?
Kind regards,
Tenttu

Yes, it is/was by design. (Funny enough, my Excel won't allow dots, only dashes (-), so I couldn't even test if "15.8" works)
So, there's a slight chance that the language of Excel (the defaults of time (24 hours or AM/PM), dates (MM/DD or DD/MM), decimals (comma or dot) etc.) wouldn't allow the dot at after the month. Here's an example of a user that has that dot, and wants to get rid of it. So, your system language is a good candidate for why this wouldn't work for you.
However, I realize that the example linked above don't feature a date with a dot at the end. Which could suggest it is rather by design. For example, if I add a dot to a valid date or time, it will result in some #VALUE!-error. And that's because of how Excel is programmed to convert text to a date - and remember, dates are actually just really large numbers. So, adding a dot at the end makes that conversion "impossible". We might think it's as easy as to remove a dot, but in programming, we need to program that explicitly to do that, and I'm leaning towards there is no such operation done during text to date conversion (certainly not on my system, as I get #VALUE!).
One work-around is to strip the ending dot from the date to make it a valid date. So, you can import sheets with dates with dots at the end, then strip them away, and you'll be good to go!

Related

Excel won't wort mixed dates

I downloaded a file from a government source. There is a column of dates in mixed formats. Some appeared 12-25-99 while others were 25-Dec-99 and some were 12/25/99. I want to sort them newest to oldest. There are over 600,000 records but I tried everything on a sample of about 25 to save time.
I managed by brute force to get them all looking the same: 12/25/99. There is nothing I can do to get them to sort. Some of the list sort because they were all the same format to start with, generally 12-25-99 though it might have been 25-12-99. No matter. The ones that had slashes never integrated with the ones that started out with dashes.
I found 6 or 7 ideas on this site but none of them worked. Help if you think you can.
Thanks.
The data samples you list suggest that what you perceive as "dates" is at least partly text. Excel internally stores dates as numbers, with day values before and time values after the decimal point (or decimal comma, depending on your regional settings). These numbers can now be formatted to appear as dates.
To check which of the "dates" are really dates, select them all and change the format to "General". Any real dates will now show as numbers, whereas any "dates" that are really just text, will remain unchanged.
In order to sort this data chronologically, you will need to convert the text values to real dates.
There are several different approaches you could use for that. You could use a formula like DateValue() - this works well with text that has the date and month in the same order as your regional settings. So, if you use US settings with MDY order of a date, give that a try.
Otherwise, and especially if the original dates are a mix of DMY and MDY order, you will need to use more sophisticated data cleanup techniques, like Text To Columns or Power Query.

Convert hebrew day-of-the-month to letter(s) in Excel

If I display a date in cell A1 using the cell format [$-8040D] d to show the day of the jewish month, I get a number (from 1 to 30) instead of -the way it is normally displayed- a hebrew letter.
So I want to use
=CHOOSE(A1,"א","ב","ג","ד","ה","ו","ז","ח","ט","י","יא","יב","יג","יד","טו","טז","יז","יח","יט","כ","כא","כב","כג","כד","כה","כו","כז","כח","כט","ל")
But even though I see a number 1-30 displayed in A1, what's really there is a date serial code (something like "44181").
I have tried N(), and VALUE().
What's the correct way to do it?
Thanks!
Excels stores dates numbers as per the Gregorian calendar with 1 = 1 Jan 1900 (and 1900 erroneously being deemed a leap year for competitive reasons).
So first you need to convert the date to the Jewish date (I'm assuming the Jewish Lunar calendar); extract the day of the month(with the TEXT function), and then convert that value to its Hebrew letter equivalent.
eg:
=CHOOSE(TEXT(A1,"[$-he-IL,8]dd"),"א","ב","ג","ד","ה","ו","ז","ח","ט","י","יא","יב","יג","יד","טו","טז","יז","יח","יט","כ","כא","כב","כג","כד","כה","כו","כז","כח","כט","ל")
or:
=CHOOSE(TEXT(A1,"[$-8040D]d"),"א","ב","ג","ד","ה","ו","ז","ח","ט","י","יא","יב","יג","יד","טו","טז","יז","יח","יט","כ","כא","כב","כג","כד","כה","כו","כז","כח","כט","ל")
So for today which is
the formula would return
The "correct" way to do it is to realize there is no problem here, no problem at all.
Yes, Excel uses a serial number dating system. However, it completely knows how to interpret it too. So you will have a serial number as the "real" content of A1, but can extract from it the day of the month value. You can do this with:
=TEXT(A1,"d")
This gets you a TEXT "6" if it is December 6. Often that fact (that it returns TEXT) can cause trouble. But only when Excel could expect you could mean either and has to guess which. In the case of the above formula it would be reasonable for it to assume you wanted it looked at as text since the function is... TEXT()...
But in this case, using it in the CHOOSE() function it can ONLY be useful if Excel treats it as a value rather than text. So it does. No need to add anything to force Excel to do so.
So you can just replace the A1 portion of your formula with the above TEXT() function. Then Excel will use it properly and select the correct day of the month from the list.
And that's all you need.

Wrong format of a cell in Excel

I am copying large tables from a website to Excel and it is copied in a wrong format. The number which I need seems to be in a cell but when I click into the cell it shows me that it is a date (and the number shown in the cell is its month and year).
Is it possible to change that so that the number in the cell will be 4.25 instead of 1.4.2025?
Thanks a lot.
You can change the format by highlighting the cells, right clicking selecting the format cells option. It will not change the string of numbers from 1.4.2025, but you will be able to replace the date format with something more appropriate for your needs. *
In the 1900 date system, 1.12 and 12.15 (for example) if entered as 1/12 and 12/15 respectively (where the locale has . as the decimal separator) into cells formatted General will show 01-Dec and Dec-15 respectively. The underlying number however (ie change format from Custom to Number) is 42339 for both. 42339 in Short Date format shows as 01/12/2015.
Although generally possible to deduce what malformed number gave rise to what looks like a date it is not always possible to do so. Ambiguity is greatest where the digits for the decimal or integer parts are less than 13. In addition, the locale in which the numbers were entered may play a part (since, in the 1900 date system, 3/4 for example would be interpreted as 42097 where the date convention is DMY 'UK' and 42067 where the date convention is MDY 'US').
So the answer to your question:
Is it possible to change that so that the number in the cell will be 4.25 instead of 1.4.2025?
is "Yes, but not fully reliably" (and even so would require knowledge or guessing of locale, date system and time of the conversion). Since you are "copying large tables from a website to Excel" it seem you retain access to the source data and I would recommend returning to that. On a small scale manual adjustments may be viable, on a large scale consider importing first to software without such automatic interpretation (eg Word, NotePad++) or, if possible, as character separated values imported as text. Address the delimiters with string handling there and only after that import to Excel or save in Excel format.

Joining a date and time into a single cell in Excel / VBA

I have to report basically the same information from inspections to two different clients, both of whom have provided me with an Excel spreadsheet in their own preferred format, and password protected. I have put the two sheets into my own workbook, and have managed to get 'almost' all the data on both sheets to populate from my own data. Where I am stuck though is on the time logs.
Client 'A' has each time and date in a single column, in the format "12.29.12 14:30". Client 'B' has two columns, date as "12/29/12" in the first, and time as "1430" in the second.
I'm trying to avoid having to type all the same dates and times twice - it can be several dozen lines - both to save effort and to avoid errors. What I really need to do is either concatenate the date and time from client 'B's report and put it into client 'A's, or split the date and time up in 'A's so I can put it ito 'B's. I've tried several approaches, but just end up with error codes or meaningless numbers.
Can anyone point me in the right direction?
Thanks,
Richard
Never mind... the very next thing I tried worked :-)
To anyone else reading this, the trick is not to concatentate the date and time values, but to add them together.
Richard
As you later pointed out in your own question, in order to manipulate date/times in Excel, you should add instead of concatenating.
The reason for this is that Excel stores all date/times as a number representing the number of days since January 1, 1900*. This number is stored as a 8-byte double.
Use Excel number formats to display the date/time format that you desire.
If you find in a worksheet that some cell's dates are in fact stored as text, use the DATEVALUE function.
*By default, Excel 2010 for Windows uses the number of days since 1900. There is an option to use the number of days since 1904 for compatibility with other versions.

Excel parsing (xls) date error

I'm working on a project where I have to parse excel files for a client to extract data. An odd thing is popping up here: when I parse a date in the format of 5/9 (may 9th) in the excel sheet, I get 39577 in my program. I'm not sure if the year is encoded here (it is 2008 for these sheets).
Are these dates the number of days since some sort of epoch?
Does anyone know how to convert these numbers to something meaningful? I'm not looking for a solution that would convert these properly at time of parsing from the excel file (we already have thousands of extracted files that required a human to select relevant information - re-doing the extraction is not an option).
Excel stores dates as the number of days since 0-JAN-1900 (so 1-JAN-1900 would have a value of "1"). You can find a really good breakdown of how Excel handles dates and times here:
Dates And Times In Excel
When dates appear on screen in Excel as "5/9", "May 9th", or some such, it is a trick of the formatting and is not representative of the underlying data value. It sounds like your parsing program is pulling the underlying value, not the formatted date. In order to suggest a fix, though, I need to know what your parsing program is (Excel macro, formula, outside code, etc.).
DateTime.FromOADate (if you're using .NET) is the method you want. Excel dates are stored as doubles. If you have dates in the first two months of 1900 you might get bit by the Excel 1900 leap year bug.
From http://msdn.microsoft.com/en-us/library/system.datetime.fromoadate.aspx:
Double-precision floating-point number
that represents a date as the number
of days before or after the base date,
midnight, 30 December 1899. The sign
and integral part of d encode the date
as a positive or negative day
displacement from 30 December 1899,
and the absolute value of the
fractional part of d encodes the time
of day as a fraction of a day
displacement from midnight. d must be
a value between negative 657435.0
through positive 2958466.0.
All you need to do is format the cells correctly. Or am I misunderstanding your question -- are you saying you want to do it OUTSIDE of Excel? I wasn't sure. I'll delete this answer if it turns out to be stupid.

Resources