+ Reply to Thread
Results 1 to 7 of 7

How to convert datetime axis to show interval in days

Hybrid View

  1. #1
    Registered User
    Join Date
    04-12-2012
    Location
    MY
    MS-Off Ver
    Excel 2010
    Posts
    10

    How to convert datetime axis to show interval in days

    I am trying to plot a line chart based on the data in the file attached but I want the x-axis to show intervals in days instead of the time date. How can this be done in Excel 2010? I tried to play around with the format axis but I can only see Horizontal (Categorical) Axis option and now Horizontal(Value) option to change it.

    Thanks.
    Attached Files Attached Files
    Last edited by purple_rain09; 08-19-2019 at 07:18 AM.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,391

    Re: How to convert datetime axis to show interval in days

    Your profile shows that you are using Excel 2007, but you say you are using Excel 2010. There's not a lot of difference between 2007 and 2010, but you might keep your profile up to date just in case it ever does make a difference.

    The obvious problem that I see when I open your file is that you don't have any true dates in your spreadsheet. Sure, you have a column of text strings that look an awful lot like dates, but Excel is very stubborn about differentiating numbers/dates stored as text and true numbers/dates. In order to use a nice date axis in a line chart, you will need to have real date serial numbers in your spreadsheet and not text that looks like dates.

    Strategies for converting numbers/dates stored as text:
    Since dates are really just numbers with special number formatting, these strategies work: https://support.office.com/en-us/art...1-c5bad0f0a885
    This page is for dates, and includes a discussion of the DATEVALUE() function: https://support.office.com/en-us/art...4-32a67ec0a680

    If you are up to some extra reading, I would recommend something like this to learn how Excel uses a date/time serial number system for storing dates and times: http://www.cpearson.com/Excel/datetime.htm
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    04-12-2012
    Location
    MY
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: How to convert datetime axis to show interval in days

    Thanks, I have updated my profile and converted the date in text into datevalue. but when I tried to plot it again, I can choose the date radio button but it is not very clear about what i should do next to specify the intervals to according to days instead of the dates instead. I have updated the attached file

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,391

    Re: How to convert datetime axis to show interval in days

    I don't have Excel in front of me, and I don't remember the exact layout of the format axis dialog for a date axis. There should be a place to set your "base unit" to either day, month, or year. There should also be options for start date, end date, and how many days (months/years) between tick marks.

    Finding those options in the dialog always seemed pretty obvious to me, so I wonder if I am misunderstanding something.
    what i should do next to specify the intervals to according to days instead of the dates instead
    I may have misunderstood until now. This suggests you want elapsed days along the horizontal axis rather than calendar dates. Charts don't analyze data for us. If you give a chart calendar dates for the horizontal axis, then it is going to show calendar dates. If you want elapsed days on the axis, then you will need to calculate elapsed days in the spreadsheet, and use that for the horizontal axis data. With your dates stored as serial numbers, this is a simple subtraction operation. =A2-$A$2 (note the mix of relative and absolute references) will give you elapsed days since the date in A2. If Excel decides to be "helpful" and format the cell as "date" it will give you dates in 1900, but the underlying value is correct. You will simply need to format the cells as general or fixed or something that is not a date. Then use that column as your horizontal axis data.

  5. #5
    Registered User
    Join Date
    04-12-2012
    Location
    MY
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: How to convert datetime axis to show interval in days

    I did exactly as what you mentioned (updated the file) but I still cannot adjust the interval values. it goes by the elapsed day values. I thought this was possible because I remember doing it in earlier versions of excel but with 2010, I am not very sure how it works anymore.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,391

    Re: How to convert datetime axis to show interval in days

    You are using a stacked* line chart with an automatic horizontal axis. Under these conditions (x axis data is formatted as regular numbers not dates), Excel is going to automatically choose a text axis. In order to be able to choose different axis divisions, your axis needs to be either a date axis (by forcing the date axis option in the format axis dialog), or you need to change your chart type to an XY scatter chart, where the horizontal axis is always a value axis. The decision will depend on exactly what kinds of divisions you want to be able to specify for your horizontal axis. If you are going to divide the axis up into a fixed number of days (7 days, 10 days, 30 days, or let Excel automatically choose), then changing to a scatter chart may be the easiest. If you want to be able to specify "calendar" type divisions (monthly tick marks), then you will want to leave it as a line chart with a date axis. My personal preference would be to use a scatter chart, but that's only my preference.

    * Were you aware you were using a stacked line chart? It doesn't matter with only one data series, but I can't tell you how many times someone has come on here with this kind of line chart with multiple data series wondering why series 2-x are not plotting at the correct value. You might make sure you understand the difference between a regular line and a stacked line and make sure you are using the correct line chart for your application.

  7. #7
    Registered User
    Join Date
    04-12-2012
    Location
    MY
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: How to convert datetime axis to show interval in days

    Thanks a lot. That explained my problem with the kind of chart i was using. I knew something was wrong because I don't remember having issues with intervals before but I have not used Excel in years and mainly using python these days to visualise data but for the work I am doing now, I just needed to use Excel. Now my chart looks like how it should be. Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. convert to datetime
    By uinthas in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-07-2017, 05:42 PM
  2. datetime interval with date axis
    By am_hawk in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 04-13-2016, 01:02 PM
  3. Show minimum and maximum value from datetime
    By DMTSpyro in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-06-2014, 11:53 AM
  4. calculate 2 datetime and returning to days and hours
    By remie in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-01-2014, 10:29 AM
  5. Plotting unequal days interval in x axis
    By thong127 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 12-11-2013, 11:59 AM
  6. Powerpivot: Convert Datetime to Weekly format (mm/dd - mm/dd)
    By thagasa in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-14-2013, 07:40 PM
  7. Based on a Column datetime value auto calculate and populate a datetime range
    By rajashanmuga in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-22-2010, 04:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1