Suggestion
Depending on context, the DATEVALUE()
function may be useful. Look into that.
Existing functions make your solution portable and predictable, which will contribute to robustness. Creating similar solutions ad hoc often introduces additional source(s) of error.
Without more specific info about how you receive your dates, how they are transferred to Calc and how your data are otherwise laid out, it is hard to provide any specific advice.
EDIT:
Based on your comment indicating that you get multiple dates from a client, laid out in a tabular setup
I would add a column (*) when you have acquired the client data.
DATEVALUE()
works on text content, which is indicated by the apostrophe you mention. Dates properly entered will be internally represented as the same number, regardless of formatting. When you create a formula in a new cell, that same numerical representation will receive the default formatting of your choice. So your new column will need to use DATEVALUE() if submitted date is represented as text, and the data (original “date value”) as entered otherwise.
See attached file for a proposed solution.
(*) All data conversions of this kind (interpreting “human-friendly” data formats) carry some risk of error. When you keep the converted date with the original instead of replacing, it is easier to catch and correct such errors.
To your other question
Yes, if you must.
You could convert everything to text values by using the TEXT()
function, and take it from there. As far as I can see, that would require a few additional steps, which also means a couple of places to make mistakes.
While converting everything to text, so “all is what it looks like”, may seem logical, this removes the exact date representation first. The important content for calculations, sorting and grouping is that exact, “presentation independent”, numerical date representation which I have suggested you create by the use of DATEVALUE()
and which you will also achieve by the text-to-columns procedure (and which, by default, will receive a visual, human-readable date representation unless you deliberately format the cells otherwise).
EDIT 2:
Based on your attached sample files
The dates in your files are all text.
To convert:
- Select the column of dates
- Menu item
Data
- text to columns
- Click the column header in the preview pane (bottom of the dialog)
- Select the appropriate date format for column type (dropdown just above the preview pane)
- OK
This worked fine for me without changing locale for file or cells. None of the cells carried the apostrophe you mentioned, but I inserted one manually in a couple of cells, and they were also converted correctly.
My locale is Norwegian, but English month names were interpreted correctly. Croatian month names are significantly different from English names, which may be the cause if the above procedure does not work. If so, try to change the cell language/locale setting and run text to columns again.
Setting language/locale for a cell range:
See menu item Format
- Cells
. There is a language selection in the Text tab, and one in the Numbers tab. Either one set to English (USA)
may work. You will just have to try. The one in the Numbers tab will select a different default date format (the one Lupp expressed rather hostile emotions towards
) but as mentioned earlier, formatting is presentation and can be changed at will, as long as content is properly set to a number representing a date.