Changing Date Format Doesn't work?

Discuss the spreadsheet application
Post Reply
geoffr
Posts: 5
Joined: Fri Feb 04, 2011 7:00 am

Changing Date Format Doesn't work?

Post by geoffr »

Trying to change the date formatting from 21/08/1961 to 1961-08-21 in order to import into our database. However, when reformatting the column accordingly the date format does not appear to change.

Is there a trick or is this a bug?

thanks,
Geoff
OpenOffice3. Mac OSX
User avatar
Villeroy
Volunteer
Posts: 31365
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Changing Date Format Doesn't work?

Post by Villeroy »

You are dealing with text data where "21/08/1961" is just a character sequence of 8 digits and 2 slashes.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
geoffr
Posts: 5
Joined: Fri Feb 04, 2011 7:00 am

Re: Changing Date Format Doesn't work?

Post by geoffr »

Mmm so how can we convert this to a date. It works perfectly in Excel.

Geoff
OpenOffice3. Mac OSX
User avatar
Villeroy
Volunteer
Posts: 31365
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Changing Date Format Doesn't work?

Post by Villeroy »

No, it does not work perfectly well in Excel but that's a different story. Converting wrong data is one thing. I would bother if there are wrong data types in your document and how they got into the sheet. Ctrl+F8 highlights all values.

http://www.yogeshguptaonline.com/2009/1 ... -date.html
Many of us get into a situation when the dates in our data are coded as text. Excel does not recognise such text entries as date and we can not use them for any calculation purpose. However you can easily covert them to date by the help of excel formula.
It is easier to do the converion in Calc.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Changing Date Format Doesn't work?

Post by acknak »

Here's one thing you can try:

Select the column with your (text) dates.

Data > Text to Columns

Delimiter: Tab (or any character that does NOT occur in the column)

In the preview grid, select the column (click in the header, marked "Standard") change the type to "Date (DMY)"

OK

Your text dates should now be converted to numeric values and should respond to the cell/number formatting to display whatever format you want.

Alternatively, and this may be preferable to preserve the text data, you can insert a new column and convert the text dates by a formula, something like

=DATE(RIGHT(A1;4);MID(A1;4;2);LEFT(A1;2))

where A1 contains a date as text in the format you showed above.

Using the formula means that the original data are preserved intact.
AOO4/LO5 • Linux • Fedora 23
User avatar
Villeroy
Volunteer
Posts: 31365
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Changing Date Format Doesn't work?

Post by Villeroy »

acknak wrote:Data > Text to Columns
... which fails if the cells are text formatted.
acknak wrote:=DATE(RIGHT(A1;4);MID(A1;4;2);LEFT(A1;2))
... which is the same method as described for Excel in my link http://www.yogeshguptaonline.com/2009/1 ... -date.html
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply