LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Compare months in Year-Month format

    Employee
    Posted 07-04-2012 08:45

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: epetrou

    Hello all,

    i would like some help with a rule i want to set in a node.

    I have 2 columns with month data in the format "2011-05" without the quotes saved as string (imported that way) .For example (copied from BRD) :

    *all data are string*
    Month Type activation_month
    2011-12 Port in 2011-12
    2011-08 Port in 2011-08
    2012-03 Port in 2012-03
    2012-05 Port in 2012-05
    2012-01 Port in 2012-01
    2012-01 Port in 2012-02

    I will tell you upfront what i want to do.I want to set a rule that if month figure is more than 13 months compared to activation_month ,exclude it,or create a new column with separator 0 or 1 or something like that.For example:if month=2011-01 ,and activation_month=2012-03(or 2012-04 or other months as we progress in 2012) i want that line excluded.
    the problem with this is i have data from 2010-05 and will update the months as we go on in 2012 ,in 2013 etc....I could do it manually but its a lot of work to use "if function" for each month to make that check..

    So in other words i want something to count the period between the 2 month columns and identify if its longer than 13 or not.Problem with that is the year changes its not always 2011 or 2012 so i could compare the months between easily.I want it also to count the change of the year as the 13 month period.Another example of my logic would be: if month=2010-12 and activation_month >= (?) 2012-01 then exclude it otherwise keep it.

    i brainstormed a little and figured that to do it i first have to change the string data to something(date format??)so that i can crosscheck the months between them.Another way would be to use the between function and set the 13 months period i want,but as string i cant do any of this and i dont know how to change the format.i tried the isDate but checking BRD after it is still saved as string.

    Can you help me ?


  • 2.  RE: Compare months in Year-Month format

    Employee
    Posted 07-04-2012 12:45

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Tim Meagher

    Hey,

    I've attached a graph which I think does what you want.
    The conversion to date is done using the date(String inputField, String dateFormat) function.
    Since dates include days, months & years, not just years and months, within the filter I've added something to the date string to assume that all of the input dates occur on the first of the month.
    The dateSubtract method can then be used to calculate the number of months between the two dates & you can use this to determine how to output the data as shown in the attached graph.

    Hope this helps.
    Tim.
    Attachments:
    DateExample.brg