Increment a date by a number of months

Welcome to our Forums Technical Support Support Desk Increment a date by a number of months

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8751
    david brown
    Participant

      I am making a graph wherein the x axis are date values. Those values are one per month, spanning several years. So, the column of dates is 12/1/2011, 1/1/2012, 1/2/2012, etc. I would like the axis to have a tick mark every third month, i.e. Jan 2012, April 2012, and so on.

      In the data table, the x axis is a date column containing the individual months. I am trying to use Labels as the tick marks, located in expression columns. One column of expressions would be the series of dates for which I want tick marks. I am stuck at creating an expression that will increment a date by one month. If I wanted to increment by, for example, one hour I could use as the expression: seconds(2011,1,1)+3600*(#-1) , (where # is the # column.) Every hour contains the same number of seconds. Every month does not contain the same number of seconds; consequently this method fails.

      I anticipated this would be a relatively common desire, but I have not found any posts in this forum dealing with it. I did a Google search on the issue (searches such as “increase POSIX time by one month”) to no avail – although I am only part way through the 10,000,000,000 search results 🙂

      I would appreciate any help anyone might be able to offer.

      • This topic was modified 1 year, 11 months ago by david brown. Reason: Clarification
      #8753
      dgteam
      Moderator

        Hi David!

        To start, we posted an example file to illustrate how to generate a column of dates that increment by a month.

        This uses a technique similar to what is shown in this article, but for dates.

        https://community.visualdatatools.com/datagraph/knowledge-base/number-series/

        This article also shows how to fill in a list of numbers.  We don’t have this similar functionality for dates but could be something to add. For now you would have to use an expression as demonstrated in the example file.

        Please take a look at the file and let us know if this helps to answer your question. Go to File > On-line examples. 

         

        #8754
        david brown
        Participant

          Thank you for a very useful and quick response. I learned quite a bit by studying your example file. It is a clever solution. Thanks, also, for the link to the article; I had not yet seen it.

        Viewing 3 posts - 1 through 3 (of 3 total)
        • You must be logged in to reply to this topic.

        Welcome to our Forums Technical Support Support Desk Increment a date by a number of months