Home ยป Forum ยป Author Hangout

Forum: Author Hangout

Excel question

Switch Blayde ๐Ÿšซ

I have a spreadsheet that originally was created from a KDP download (Generate Report on the sales stats page). The first column is Date formatted as "general". The contents look like "2020-12-06".

I use the same spreadsheet to track Bookapy sales as well. So I copy a row generated by KDP for that novel and modify certain fields. One field I modify is the date. When I do that, it messes up the contents of the field. I get around it by putting a ' before the number, but the original field doesn't have that.

When I copy the field, say "2020-12-06", it looks fine. However, when I change the "6" to an "8" it changes the formatting from "general" to "date" and the result is "12/8/20". When I change the format back to "general" the field gets changed to "44173".

As I said, the way I get around it is to add a ' before the 2020-12-08 and keep it as "general".

But why is it happening? Why would Excel change the formatting for the field from "general" to "date" when I modify the contents? If it's recognizing it as a date, why did it allow KDP to have a date in a "general" field without the ' ?

Replies:   Keet  Dominions Son
Keet ๐Ÿšซ

@Switch Blayde

One of the famous 'Excel is smarter than you are' problems. Change the whole column to 'text' and you're probably good.
What you do is actually one of the 'solutions' MS gives to the problem: https://support.microsoft.com/en-us/office/stop-automatically-changing-numbers-to-dates-452bd2db-cc96-47d1-81e4-72cec11c4ed8.

Replies:   Switch Blayde
Switch Blayde ๐Ÿšซ
Updated:

@Keet

Change the whole column to 'text' and you're probably good.

Aha. I changed the whole column to "general" but not "text". I'll try that.

Thanks.

ETA: "text" worked the same way "general" worked with the '

Thanks.

Replies:   Switch Blayde
Switch Blayde ๐Ÿšซ

@Switch Blayde

smarter than you are' problems.

My Audi is the same. It thinks it's smarter than me and screws up.

If I want to pull up with the driver's door open to check the curb, it puts the parking brake on. If I'm cold and press the button to stop air flowing from outside, it turns the air conditioner on. And so on.

Dominions Son ๐Ÿšซ

@Switch Blayde

Because general can be anything. I'm surprised that the date came across the import looking like "2020-12-06" because Excel's default date format is MM/DD/YYYY

It's possible it came across as text, but when you modified it, Excel recognized it as a date and converted it. Excel stores dates as an integer offset number of days since 1/1/1900*.

This is why you see an number when you force it back to general.

When you go into format cells and select date in the category, there should be a second list view that shows specific types of data formats. One of these should give you the YYYY-MM-DD format. In the version I have this list populates with examples using 3/14/2012 rather than showing raw formats so the choice you want would be "2012-03-14".

*There is a bug in Excel's handling of leap years which will cause a problem with dates between 3/1/1900 and 1/1/1900. Basically Excel thinks 1900 was a leap year and it wasn't.

REP ๐Ÿšซ

@Dominions Son

Basically Excel thinks 1900 was a leap year and it wasn't.

Check 1900 again and you will find that it is a leap year (i.e. divisible by 4 with no remainder).

Replies:   Dominions Son
Dominions Son ๐Ÿšซ

@REP

Check 1900 again and you will find that it is a leap year (i.e. divisible by 4 with no remainder).

Nope, Century years are only leap years if they are divisible by 400.

https://en.wikipedia.org/wiki/Century_leap_year

Replies:   Akarge
Akarge ๐Ÿšซ

@Dominions Son

correct. It has only happened a few times. 1700, 1800, 1900. Next one is 2100. The correction from the old calendar happened in 1582.

Replies:   Dominions Son  solitude
Dominions Son ๐Ÿšซ

@Akarge

It has only happened a few times. 1700, 1800, 1900. Next one is 2100.

None of those are leap years. The next century leap year will be 2400.

Replies:   akarge
akarge ๐Ÿšซ

@Dominions Son

I was listing the century dates that WERE NOT leap years.

Replies:   Dominions Son
Dominions Son ๐Ÿšซ

@akarge

Yes, that is what you did, but the proceeding text does not make sense in reply to my comment if that was your intent.

Me:

Nope, Century years are only leap years if they are divisible by 400.


You:
It has only happened a few times.


Actually, it has only happened twice. It being a century year being a leap year by being divisible by 400. Those instances would be 1600 and 2000.

solitude ๐Ÿšซ

@Akarge

The correction from the old calendar happened in 1582.

Different countries adopted the calendar in different years/centuries, so you can't give a single date to when the correction occured (without adding country info).

Replies:   Dominions Son
Dominions Son ๐Ÿšซ

@solitude

Unless you are suggesting that there are countries that didn't adopt the correction until after 1600, it's not really relevant to the discussion at hand.

Replies:   Ernest Bywater
Ernest Bywater ๐Ÿšซ

@Dominions Son

Unless you are suggesting that there are countries that didn't adopt the correction until after 1600, it's not really relevant to the discussion at hand.

https://en.wikipedia.org/wiki/Gregorian_calendar#Adoption_by_country

1582 Spain, Portugal, France, Poland, Italy, Catholic Low Countries, Luxemburg, and colonies
1584 Kingdom of Bohemia
1610 Prussia
1648 Alsace
1682 Strasbourg
1700 'Germany',[Note 6] Swiss cantons, Protestant Low Countries, Norway, Denmark
1752 Great Britain and colonies
1753 Sweden and Finland
1873 Japan
1875 Egypt
1896 Korea
1912 China, Albania
1915 Latvia, Lithuania
1916 Bulgaria
1918 Russia, Estonia
1919 Romania, Yugoslavia[Note 7]
1923 Greece
1926 Turkey
2016 Saudi Arabia

more detailed list at

https://en.wikipedia.org/wiki/Gregorian_calendar#Adoption_by_country

Switch Blayde ๐Ÿšซ

@Dominions Son

It's possible it came across as text,

Nope. When I check the formatting of the field in the spreadsheet generated by KDP it is "general" without the '. So when I copy the row to my spreadsheet it's still "general" and without the '. It's only when I modify the date that Excel messes it up.

Replies:   Dominions Son
Dominions Son ๐Ÿšซ

@Switch Blayde

If it came across correctly as a date with a general format, you should see a big integer like 44173 because that's how Excel stores dates.

Replies:   Switch Blayde
Switch Blayde ๐Ÿšซ

@Dominions Son

If it came across correctly as a date with a general format, you should see a big integer like 44173

But it displays as a date even though it's "general" and it does not have the '.

It's only when I modify it (and keep it as "general") that it converts it to the large integer. That is what's confusing me.

Replies:   Dominions Son
Dominions Son ๐Ÿšซ

@Switch Blayde

It's only when I modify it (and keep it as "general") that it converts it to the large integer. That is what's confusing me.

It's MS Excel. Confusing users is a major goal. :)

Keet ๐Ÿšซ

@Dominions Son

because Excel's default date format is MM/DD/YYYY

No it's not, it defaults to Windows culture settings.

awnlee jawking ๐Ÿšซ

@Dominions Son

*There is a bug in Excel's handling of leap years which will cause a problem with dates between 3/1/1900 and 1/1/1900. Basically Excel thinks 1900 was a leap year and it wasn't.

No, it's a 'facility'.

The bug was in Lotus123 and Excel was an unknown with M$ desperate to win conversions. It took the decision to replicate the Lotus bug for data compatibility.

I'd be interested to know whether OOCalc has the same 'facility'.

AJ

Dominions Son ๐Ÿšซ

@awnlee jawking

It took the decision to replicate the Lotus bug for data compatibility.

But with Lotus long gone and hundreds of users complaining about it, they still refuse to fix it.

Dominions Son ๐Ÿšซ

@awnlee jawking

I'd be interested to know whether OOCalc has the same 'facility'.

I just tested OO by entering 2/1/1900 and streatching it out to an auto fill series, it correctly goes from 2/28/1900 to 3/1/1900 with no 2/29/1900.

Replies:   awnlee jawking
awnlee jawking ๐Ÿšซ

@Dominions Son

Thank you. Kudos to OO.

AJ

awnlee jawking ๐Ÿšซ

What format is the KDP download? Is it a spreadsheet? If so, could it be carrying formatting information with it?

AJ

Replies:   Switch Blayde
Switch Blayde ๐Ÿšซ

@awnlee jawking

What format is the KDP download? Is it a spreadsheet? If so, could it be carrying formatting information with it?

Yes, it is a spreadsheet.

When I check the formatting of the field in the generated spreadsheet it is "general" and it does not have the ' in front of the date.

awnlee jawking ๐Ÿšซ

@Switch Blayde

when I change the "6" to an "8" it changes the formatting from "general" to "date"

It may not apply to Excel, but I'm pretty sure you have to enter dates using something like CTRL/D on some spreadsheet types. Perhaps experienced Excel users know more.

AJ

Replies:   Dominions Son
Dominions Son ๐Ÿšซ

@awnlee jawking

It may not apply to Excel

That doesn't apply to either Excel or OO Calc. They will recognize dates entered in any supported format and automatically convert them under the hood.

Replies:   awnlee jawking
awnlee jawking ๐Ÿšซ

@Dominions Son

Thanks.

AJ

Dominions Son ๐Ÿšซ
Updated:

@Switch Blayde

Yes, it is a spreadsheet.

What format specifically? .xls, .xlsx, .odx, something else?

Note: Excel will open .cvs files as if they were a spread sheet, without doing an import, but it's not actually a spreadsheet.

.cvs (comma separated values) is just a text file with comma delimited values.

If what you are getting from KDP is a .cvs file, there's your problem. It's all just text data until you do something that makes Excel actually process the value in a particular field.

Replies:   Switch Blayde
Switch Blayde ๐Ÿšซ

@Dominions Son

What format specifically? .xls, .xlsx, .odx, something else?

xlxs

Keet ๐Ÿšซ

@Switch Blayde

When I check the formatting of the field in the generated spreadsheet it is "general" and it does not have the ' in front of the date.

From the link I put in my first answer:

An apostrophe (') before you enter a number, such as '11-53 or '1/47. The apostrophe isn't displayed in the cell after you press Enter.

(I added bold)

The row you copy from doesn't have the ', maybe because of this. Your fields shouldn't either after you put in an apostrophe, then the date , and press Enter.

Switch Blayde ๐Ÿšซ

@Keet

Your fields shouldn't either after you put in an apostrophe, then the date , and press Enter.

But the ' stays in the field after hitting Enter or clicking on the check sign.

Replies:   Dominions Son
Dominions Son ๐Ÿšซ

@Switch Blayde

But the ' stays in the field after hitting Enter or clicking on the check sign.

If you are seeing the ' what's in the cell is already text data.

When you change the date, are you editing the string in the field or entering a whole new date from scratch.

If you enter a date from scratch, Excel will automatically convert it and set the cell format to a date type.

awnlee jawking ๐Ÿšซ

@Keet

I don't have Excel on this machine so I can't check, but does Excel have a formula bar showing the formula of the current cell (as opposed to the cell showing the display value) and does that show the apostrophe?

AJ

Replies:   Switch Blayde
Switch Blayde ๐Ÿšซ

@awnlee jawking

does Excel have a formula bar showing the formula of the current cell (as opposed to the cell showing the display value) and does that show the apostrophe?

If you click on the cell, there's a place where it shows the text of the cell or the formula if it's a formula. In this case it's not a formula so it shows the text with the apostrophe.

In the cell in the spreadsheet itself, it displays as:
2020-12-08

but in the place where the contents or formula shows, it displays as:
'2020-12-08

Replies:   awnlee jawking
awnlee jawking ๐Ÿšซ

@Switch Blayde

Thanks.

What about the original contents.I presume the spreadsheet cell itself displayed as
2020-12-08
but how did it display the formula?

Sorry, I'm asking a lot of questions without offering much help but I'm interested in the answers because I have problems with transferring dates between software packages (including spreadsheets) and I often use the same workaround you resorted to!

AJ

Replies:   Switch Blayde
Switch Blayde ๐Ÿšซ

@awnlee jawking

What about the original contents.I presume the spreadsheet cell itself displayed as
2020-12-08
but how did it display the formula?

It displays as 2020-12-08 in both the spreadsheet and the formula (and the format is "general").

That's what I don't understand. It's treating it as if the format is "text" but it says it's "general".

Replies:   Keet  bk69
Keet ๐Ÿšซ

@Switch Blayde

That's what I don't understand. It's treating it as if the format is "text" but it says it's "general".

Read 'general' more like 'whatever I can make of it'. 'text' is what it says, just text.

Switch Blayde ๐Ÿšซ

@Keet

Read 'general' more like 'whatever I can make of it'. 'text' is what it says, just text.

But if the date is text rather than a date, and it doesn't have the apostrophe, why doesn't it come across with the cell defined as text in the generated spreadsheet?

I don't expect you to know the answer. I'm just describing what doesn't make sense to me.

Dominions Son ๐Ÿšซ

@Keet

@Switch Blayde

That's what I don't understand. It's treating it as if the format is "text" but it says it's "general".


Read 'general' more like 'whatever I can make of it'. 'text' is what it says, just text.

Once 2020-12-08 is actually in the file for a given cell location, Excel won't know how to handle it as anything other than text. A date should have an integer in the raw data for the cell.

If KDP is somehow building the .xlsx without using Excel or converting from a .CVS that's something that can happen.

Replies:   Keet  Switch Blayde
Keet ๐Ÿšซ

@Dominions Son

Once 2020-12-08 is actually in the file for a given cell location, Excel won't know how to handle it as anything other than text. A date should have an integer in the raw data for the cell.

Not if you change the text, it's just interpreted again.

Replies:   Switch Blayde
Switch Blayde ๐Ÿšซ
Updated:

@Keet

Not if you change the text, it's just interpreted again.

Which is what happens. It displays correctly UNTIL the value is changed. Then Excel recognizes it as a date and reformats it as "date" (unless I first change from "general" to "text" or add the apostrophe and leave it as "general."

Switch Blayde ๐Ÿšซ

@Dominions Son

If KDP is somehow building the .xlsx without using Excel or converting from a .CVS that's something that can happen.

I bet that's what's happening.

1. I opened a new spreadsheet.
2. I made the cell "text"
3. I entered "2020-12-08" and it was fine
4. I changed it to "2020-12-09" and it was fine
5. I changed it to "general" and it was fine
6. I changed it to "2020-12-08" and Excel made it a "date"

So I got the data into the cell before it was defined as "general." Then changing it to "general" had no effect โ€” until I changed the data in the cell within Excel.

So KDP must be populating the spreadsheet outside of Excel. And it displays fine until I change the data.

Replies:   Dominions Son
Dominions Son ๐Ÿšซ

@Switch Blayde

And it displays fine until I change the data.

At which point, Excel goes "hey, this looks like a date" and does a whole bunch of stuff for you under the hood.

bk69 ๐Ÿšซ

@Switch Blayde

That's what I don't understand. It's treating it as if the format is "text" but it says it's "general".

IIRC, prepending the apostrophe will override the default format for the cell and cause the cell to be displayed as justified text.
Also, unless the exact date format identical to what was used in the import is your default date format, I don't think date format will be used - but when you enter any date data into a text field excel assumes you want to use its date formatting.
Nobody ever claimed M$ wrote decent code. Or logically internally consistent, for that matter.

Dominions Son ๐Ÿšซ

@bk69

Also, unless the exact date format identical to what was used in the import is your default date format

Not quite.

1. In doing an actual import if you declare a column as date, you can select the format to use, it is not limited to the default date format.

2. Excel will open a .csv file without doing an import. Anything that isn't strictly numeric will be treated as text.

awnlee jawking ๐Ÿšซ

@bk69

Or logically internally consistent

That's the biggest problem, IMO. You always seem to need workarounds.

AJ

richardshagrin ๐Ÿšซ

"general"

If you admire it, it is Admirable, it goes to sea.
"Is a general higher than an Admiral?
The only difference is that Admiral is a rank in the Navy and General is the rank in Army. Admiral is a top rank or part of a top rank in the Navy. Admiral is a rank just above the vice admiral and below Fleet Admiral or Admiral of the Fleet. ... General is a top peacetime rank in the Army."

Some are Vice Admirals, because they engage in vice. Some are Rear Admirals, who are more into rear activities. Sometimes the upper half, sometimes the lower half.

Dominions Son ๐Ÿšซ

My guess at this point is that SB is actually dealing with a CSV file, not an actual spreadsheet.

Switch Blayde ๐Ÿšซ

1. If I copy the KDP generated field (the date without the apostrophe) into a different line and change the date, Excel changes the formatting to "date" and messes up my formatting.

2. If I copy it and change the formatting to "text" before changing the date, it works fine.

3. If I copy it and add the apostrophe before changing the date (the format is still "general"), it works fine.

I've been doing #3. #2 takes more steps so I'll continue to do #3.

I still can't figure out why the format of the cell I get from KDP is "general" and not "text" when it's operating like "text" (a date without the apostrophe).

Replies:   Dominions Son
Dominions Son ๐Ÿšซ

@Switch Blayde

I still can't figure out why the format of the cell I get from KDP is "general" and not "text" when it's operating like "text" (a date without the apostrophe).

I'm not sure how KDP is generating the .xlsx file.

They may be generating a .csv, then converting it to .xlsx.

But in general, if the cell contains any characters other than +-=.1234567890 Excel and any other spreadsheet will treat the data as text, with or without the ' unless the text matches a defined date format.

= as the first character in the cell will make it interpret the cell value as a formula

+ or - would have to be at the start of a string of digits. Without either = or ' 2010-03-25 can only be text or a date. And the value of a cell in the actual file for a date would be an integer and Excel converts the integer to a date when it renders the cell value.

This is why I suspect that they first created a CSV and later used Excel or some other tool to convert it to a .xlsx. When Excel loads a CSV, it will treat everything that isn't a straight number as text.

It's the only path I can think of to get 2020-12-08 into a cell in the file itself.

Back to Top

 

WARNING! ADULT CONTENT...

Storiesonline is for adult entertainment only. By accessing this site you declare that you are of legal age and that you agree with our Terms of Service and Privacy Policy.


Log In