Date format won't change

Discuss the spreadsheet application
Post Reply
stankoprowski
Posts: 9
Joined: Sun Mar 23, 2014 5:47 pm

Date format won't change

Post by stankoprowski »

I have a small CALC contact list and I'm trying to sort by date. I've tried right-click on the column/numbers/date/12-31 to give a date without year. If I select a date like 12-31, in the edit box(?) I get a different format, 12/31/2014 which I can't change. For example when I try to sort dates the third month is split into 3 groups separated by other dates. If I select the first group the edit box(?) shows 03/XX/2012. The second group 03/XX/2014 and the last 03/XX/2015. I believe the year dates are the year the row was created and are affecting the sort. In my file the years are in a separate column

What am I doing wrong? How do I get the 12-31 format in both the column and the edit box(?) so I can do the sort that I want?

Stan
Open Office 4.0.0
Windows XP
User avatar
Zizi64
Volunteer
Posts: 11511
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Date format won't change

Post by Zizi64 »

Formatting a datetime value not eliminate the 'year' part, but just hide it only.
You need convert the values by some furmula for "normalize" (eliminate) some part of the datetime value.
The you will able sort them as you want.

The 'Datetime' is a numeric value. The integer part represents the 'year', 'month', 'day' parts (it means: the number of days elapsed since the base date), and the fraction part represents the rest 'hours', 'minutes', 'seconds'.
Last edited by Zizi64 on Sun Feb 22, 2015 9:22 pm, edited 1 time in total.
Tibor Kovacs, Hungary; LO7.5.8/25.8.5.2 /Win7-10-11 x64Prof.
PortableApps: LO3.3.0-25.8.5.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
keme
Volunteer
Posts: 3799
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Date format won't change

Post by keme »

Like Zizi64 said, a date value will always have a "year component".
Your suspicion is correct: If you don't specify the year when entering a date, Calc will assume current year. Calc does not have any "input mask". Formatting only applies to display.
(Exceptions are fraction formats and text formatting, which hints Calc towards how the input be interpreted, but still do not provide an input mask as such.)

To avoid Calc's assumptions when you enter day/month, you need to avoid the datevalue data type. Mostly it is recommeded to format your input cells as text for this purpose. If you need the proper datevalue (e.g. for sorting), you use a formula to interpret the entered digits as a date. String extraction functions (LEFT/MID/RIGHT), VALUE and DATE may be useful for that.

To sort all dates within a year (s you would to create a birthday list), you use same year for all in the DATE() function, just picking the day and month from entered data.

Hope this makes some sense...
Apache OO 4.1.16 and LibreOffice 25.8, mostly on Ms Windows 10 and 11.
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Date format won't change

Post by RusselB »

The edit box will always show the recognized date, usually in one of two formats. The first is as you have already seen, the second is as an integer that represents the number of days since the system base date.
One option is to use a couple of helper columns. If your dates are in column A, enter

Code: Select all

=month(A1)
in column B and

Code: Select all

=day(A1)
in column C
Then set your data range to include columns A-C, and sort with column B as your primary key and column C as your secondary key.
This will sort your data ignoring the year portion, thus Feb 10 1902 will have the same sort value (for lack of a better term) as Feb 10 2102
Normally when dates are being sorted, the year is wanted to be part of the determination for the sort, but you're requesting otherwise.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
stankoprowski
Posts: 9
Joined: Sun Mar 23, 2014 5:47 pm

Re: Date format won't change

Post by stankoprowski »

Thanks all. I changed the date to text and while it's not pure it does what I needed. I had to re-enter the data because XX-XX changed to a 5 digit number.

Stan
Open Office 4.0.0
Windows XP
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Date format won't change

Post by RusselB »

The only difference between the XX-XX format and the 5 digit number is the format. To Calc they are identical
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
stankoprowski
Posts: 9
Joined: Sun Mar 23, 2014 5:47 pm

Re: Date format won't change

Post by stankoprowski »

Thanks I figured something like that. Looks like a Star Date or something.

Stan
Open Office 4.0.0
Windows XP
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Date format won't change

Post by RusselB »

It's the number of days since the date specified in the settings as the system start date
For AOO that date is Dec 30 1899 (by default), StarCalc 1.0 uses Jan 1 1900, and some other spreadsheet programs use Jan 1 1904
If you enter the number 0 into a cell, then format it as a date you'll get one of those three.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
Post Reply