Getting date to by in 'XX format for chart - excel

I have data formatted as follows:
Year: Value
2002 4
2004 8
2010 3
...
When I plot the data the x axis tick marks are labeled as follows:
2002, 2004, 2010.
I would like them to be '02, '04, and '10.
However, when I change the custom format to yy, they all get switched to 05 (each tick mark has the same value).
How do I fix this to get what I am looking for?

Ensure your years that you entered in your cells are actually Excel date serial. Ie when you change the date format on the cells do they display differently? 2010 can be the number 2010 not the year 2010. As such enter your dates as 2010/01/01 or what ever pattern matches your system. Just make sure that it is an actual date. Once you have done that you can then apply the custom formatting.
Note the year in cells C2:C4 are actually 2002/01/01, 2004/01/01, 2010/01/01 with custom format yyyy so that only the year is displayed.
Sequence:
1) Enter your years as years/month/date or whatever your system format is in your spreadsheet.
2) Format your spreadsheet to display YYYY in custom format so only the year is display (this is purely for aesthetics)
3) Create your XY scatter plot
4) Format your X axis
5) On the right side of your screen scroll down to the bottom and expand the NUMBER menu.
6) In the Category box, select custom.
7) In the format code box, enter yy
8) Scroll up to the top and set you bounds minimum to the days since January 1 1900 for the first day of the year you want to look at. (enter the yyyy/mm/dd, or what matches your system, in some cell and then change it format to general. The number displayed is the number of days)
9) Under units, set major to 365 or 365.25 and this should keep your intervals at roughly 1 year. The longer the spread in years the slightly weird appearance your graph may have for 365 option.

Related

How to add month and day to a numbered year in excel?

I have a column of years, 2000, 1990 > 900 (0900) > 1876 etc.... However I needed to have it in a date format e.g. 01/01/2000, 01/01/900 (01/01/0900). I can't work out how to do this. I can only see formulas which add days and months which are already in the format I would like. I only need it as 01/01 to input to QGIS as a csv file.
Dates are represented in Excel by real numbers. The integer part (to the left of the decimal place) is the number of days since 12/30/1899. The fractional part (to the right of the decimal place) is the fraction of the day. .5 = noon, .75 = 6pm, etc. How these numbers appear in the worksheet depends on the number format of the cell. So if your cell value is 36526 (or 1/1/2000) and the number format is "mm/dd/yyyy" you will see '01/01/2000' in the cell. If the number format is "mm/dd", you will see '01/01' in the cell.
I don't understand what you mean by "I only need it as 01/01 to input to QGIS as a csv file" but if you show me some code, and explain how the results you're getting differ from the results you want, I can probably help get you there.

Re-arrange Axis of MS Excel 2016 Scatterplot

Software: MS Excel 2016
Files: GitHub Repository
Referring Question: MS Excel Scatterplot converts Months to Numbers
I created scatterplot in month_unordered_axis.xlsx from following data
Then I customized X-axis so it displays only month
Unfortunately the scatterplot (in Chart1 of month_unordered_axis.xlsx) starts with October rather than January.
How to order the X-axis so it displays from January to December?
Your graph is displaying October as the minimum value from its automatic formatting of max/min values. i believe if you scroll up in that formatting window on the right while you have the X-axis selected you will see an option for min and max value. You could set this for the minimum value you in your graph to 36892. This corresponds to the integer value for you lowest date in your series. The unfortunate side effect is that half your circle will be cut off as it extends into the range that is less than your minimum value. You can also set your maximum date to 37256. There are a few other end numbers you can use to give the same results but its essentially the end of December start of January the following year that allow December to be displayed.
Now if you want every month to be displayed (which is independent of placing max min values on your graph), look for the UNITS and Major box. Since you will want ever major line displayed with the name of a month, you will need to make sure the next grid line is a month away. Since not all month are not equal in length you need to play with this number a bit to suit your needs. I started with 30 and wound up with 2 Januaries back to back. However bump it up to 31 and then it tips over into the next month.
The important thing to note here is that you are not actually graphing by months along the X-axis. You are actually plotting by the number of days since January 1st 1900. so January 1st 2001 is 36892 days since January 1st 1900. What excel is doing is counting those days, determine what the date is in a way we like to read it and displaying only the portion we want it to. So for mmmm it the full spelling of the month. And you can see why each grid line being 31 days away is needed to jump into the next month. The kicker is, the grid line is not necessarily the 1st of each month due to the over stepping that is done when you advance 31 days in a month that has 28, 29, or 30 days. and that error gets compounded through the year.
Try using 32 as theMajor Unit step first before putting min and max caps on. (31 resulted in Feb being skipped on my screen). You should still see your axis start before Jan, but your months should all be in order, all displayed and no circles being cut off. Adding the max and min to the axis will cut off your circles but limit the axis to only displaying 12 months.

Lotus Notes View Column Date Format

I have imported an excel file into a Lotus Notes database using LotusScript. One of the columns in my view (which displays the imported data) shows a date. If the year is greater than 2000, it is shown with 4 digits e.g. 2001.
However if the year is less than 2000 the year is displayed with just 2 digits e.g. 99.
Does anybody know why this is?
The date is contained in a text field. The column uses the "Date / Time" style with "Show Only month, day and year". Display Time is not selected.
In your column properties, look at the 4th tab (Advanced Format). You say you have "Date/Time" selected, and "Display Date" selected. Nex to that in the "Special" field, have you ticked "Show 4 digit year for 21st century"? If so, 20th century dates will show with 2 digits, 21st century ones with 4.
I remember when this feature was added, and thinking how cool it was. God, I feel old!

Excel: Every other date on X-axis displayed fromthe end

I have a set of dates and matching numbers in excel, one number for every month in 2013. I need to display these numbers with the dae on the X-axis in a simple line graph. I am mainly intereseted in the number for the last month but also the historical numbers.
It is to crowded on the X-axis to show every single month so I only show every other month. This is easily done by right clicking the axis etc.
Now, since the last month is the most important one I would like to show that month (2013-12) and every other month backwards.
The axis should look something like this:
2013-02, 2013-04, 2013-06, 2013-08, 2013-10, 2013-12
But no matter how I change in excel I end up with this:
2013-01, 2013-03, 2013-05, 2013-07, 2013-09, 2013-11
Since the last month (december) is the most important one I would say it is logical to display that month.
The only way I can get it working is by dropping the first observation which I don't want to do.
Any suggestions how I can et this working in excel?
You have a "fencepost problem". You want to display 12 values, but if you want to display every second one, either you take all the odd numbers (in which case december is hidden) or all the even ones (which hides january)
If you're okay with hiding january, then add a dummy month at the beginning of your series, and give it the value:
=na()
Excel will allot it space but will not give it a point on the graph.
Alternately, if your axis is too crowded, turn the label text sideways or put the year 2013 in the title and only put the months on the x axis (1, 2, 3, ..., 12)

.NumberFormat sometimes returns the wrong value with dates and times

It seems that every week or so someone posts a question about dates being converted (corrupted?) to American format. Like many others, I have attempted to help but the problem is elusive. I now wonder if I have discovered the cause.
I am working on an application in which I need to extract data from an Excel worksheet and output it as strings formatted to match the value the Excel user can see. So if the value is “1” formatted to display as “1.00” then I want the string to be “1.00”.
I achieve this effect by testing the cell value to be a number, date or time. If it is, I retrieve the number format and use it to format the cell value so:
With .Cells(Row, Column)
Output string = Format(.Value, .NumberFormat)
End With
In most cases this gives me exactly the output I require. However, sometimes I get American dates and times when the source is formatted as a UK date or time.
After much experimentation with Excel 2003 and Excel 2007, I have discovered the cause. (I do not have access to Excel 2010 but from questions I deduce it has the same problem.) This question is in part intended to reveal this problem to the world because I can discover nothing on the internet to indicate that anyone else has noticed it. (No doubt someone will reply that they googled “xyz” and got the answer immediately.) However, the main purpose of this question is to seek suggestions for obtaining the result I need in all situations.
Typically I enter dates as, for example, “23mar12”. Excel recognises this as a date and formats it as “23-Mar-12”. I can select Format Cells and enter or select a custom format or select one of the date formats so I can have any format I can imagine wanting including non-English names for days and months.
However, in one case the format I select is not the format that is recorded: Custom format “dd/mm/yyyy” is recorded as Date format “* 14/03/2001”. This is not obviously a problem until further down the line.
I created a column of dates and times and formatted each with a different custom or standard format. I wrote a macro to extract the NumberFormat for each of these dates and times and write it as a string to an adjacent column. I also formatted the value using the number format and wrote that string to a third column.
In a number of cases the format selected and recorded by Excel was not the format returned by NumberFormat:
Excel format NumberFormat
Date: * 14/03/2001 m/d/yyyy
Date: * 14 March 2001 [$-F800]dddd, mmmm dd, yyyy
Date: 14/03/2001 dd/mm/yyyy;#
Date: 14/03/01 dd/mm/yy;#
Date: 14/3/01 d/m/yy;#
Date: 14.3.01 d.m.yy;#
Date: 2001-03-14 yyyy-mm-dd;#
Date: 14 March 2001 (1) [$-809]dd mmmm yyyy;#
Date: 14 March 2001 (2) [$-809]d mmmm yyyy;#
Custom: hh:mm:ss h:mm:ss
Time: * 13:30:55 [$-F400]h:mm:ss AM/PM
Time: 13:30:55 (1) hh:mm:ss;#
Time: 13:30:55 (2) h:mm:ss;#
Time: 01:30:55 PM [$-409]hh:mm:ss AM/PM;#
Time: 1:30:55 PM [$-409]h:mm:ss AM/PM;#
The values (1) and (2) in the Excel format column were added by me to indicate that there are two apparently identical formats. As can be seen from the NumberFormat column, in each case the second version suppresses a leading zero.
Most changes have no important effect. “[$-F800]” and so on are apparently dummy values with no effect. Apparently you can replace “F800” with an Microsoft country code to have the names of days and months translated to the language of that country.
However, the three standard formats that Microsoft marks with an asterisk are changed unacceptably. The dates are changed from little endian to middle endian; the time is changed from 24 hour to 12 hour and the day of the week has been added to “* 14 March 2001”.
The asterisk against the dates, references the comment: “Except for items that have an asterisk () in the Type list (Number tab, Format Cells dialog box), date formats that you apply do not switch date orders with the operating system.” The asterisk against the time, references the comment: “Except for items that have an asterisk () in the Type list (Number tab, Format Cells dialog box), time formats that you apply do not switch time orders with the operating system.”
If I have to, I can warn my users that standard date and time formats may not give the result desired. However, if they want the popular format “dd/mm/yyyy”, they cannot have it. “dd-mm-yyyy”, for example, is OK but custom format “dd/mm/yyyy” becomes date format “* 14/03/2001” becomes “m/d/yyyy”.
Returning to my opening point: is this strange handling of one particular date format the reason so many people claim their dates are sometimes being converted to American format and is this why the problem is so elusive? I have come across this type of problem elsewhere of one group of Microsoft programmers not knowing what another group are doing. Is this why some functions always work and other sometimes don’t? Some Microsoft programmers know where to look for the correct format and others don’t?
More importantly, for me, can anyone suggest:
How I obtain the true date or time format?
Some other way of determining the user’s chosen display format for a date or time?
BTW 1: I recall that thirty or so years ago I was told that the American military do not use month/day/year format; only American civilians use this format. Can anyone tell me if this is true?
BTW 2: The similar problem is with Excel colours. Excel holds its colours as "ggbbrr" while everybody else holds them as "rrggbb". The programmers for the .Net Excel inter-op were not told and and did not reverse the Excel colour number before using it to control the screen.
I have mainly come up against formatting and date issues when opening text files which have been saved with different regional settings. Two useful cell properties for dealing with this are:
.Text returns the cell value as it is displayed
.Value2 returns the unformatted cell value or date serial number.
As you say, standard date and number formats depend on windows regional settings and this may not be desired behavior as the same workbook can display differently in different regions. MS introduced the regional code prefixes in number formats (circa Excel 2000?) which enforce consistent display if needed but they need to be explicitly selected.
If you really want to see a date or number as the user entered it, you could extract the contents of the .xlsx file looking at the worksheet cell format and the shared strings xml definitions which list the number formats in the saved workbook. I don't really see a need to do this though as the underlying value is stored internally as a serial number and this will not change.
BTW 1: It's been almost 30 years since I was in the military...
I worked on helicopters and I was taught to use a format such as this in the aircraft logbooks: 3 Apr 12. So, that's how I still write dates. This way, there's no wondering about 4/3/2012 - is it April 3 or March 4?
I hacked this: I rewrite the original data in a known format. it relies on DateSerial and TimeSerial:
'Google spreadsheet stores dates in USA format (MM/DD/YYYY). We're in Australia, using DD/MM/YYYY, so we need to swap them.
'
With dc 'the cell who contains a date in USA format.
d = .Value 'capture value in USA format
t = TimeValue(d)
.NumberFormat = "dd/mm/yyyy" 'set to OZ format, so Excel knows the values were swapped in its internal math.
.Value = DateSerial(Year(d), Month(d), Day(d)) 'DateSerial takes y,d,m. We swap Month and Day components, to get OZ format dates
.Value = .Value + TimeSerial(Hour(t), Minute(t), Second(t))
dc.Font.Bold = True ' We bold the cells that are swapped, for debugging
End With
End If

Resources