Date comparison

abbaszavarabbaszavar Member Posts: 11 Contributor I
edited December 2018 in Help

Hi there,

I have a date attribute and I want to find any date 6 months before that.

I have used "Generate Attributes" and the date_diff() function like this: date_diff(ServiceDate,01-07-2015)

but it doesn't work! what should be the format for the second date?

Any advice?

Thanks,

Abbas

Tagged:

Best Answer

  • Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn
    Solution Accepted

    @abbaszavar try using Nominal to Date operator. You will need to input the format of your date, so if you have 2017-01-18, then you must enter it as yyyy-MM-dd, then RapidMiner will automatically convert those values into date format. 

Answers

  • Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn

    So RM is finicky with the attributes you use for date_diff(). THey need to be in a numerical date-time format, hence 01-07-2015 might not work because RM considers that a polynominal/ Tha could be causing the error.

  • Telcontar120Telcontar120 Moderator, RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,635 Unicorn

    This is very easy to do, but you don't want to use date_diff here.  That's for computing the difference between two different dates.  Instead you want to use the following function: date_add(Date,-6,DATE_UNIT_MONTH)

    (This assumes your existing date attribute is called "Date").  Just put this into Generate Attributes and create your new attribute accordingly.  You can also change the amont of the date change (in integers) and also the unit of change (days, months, hours, etc).

     

    Brian T.
    Lindon Ventures 
    Data Science Consulting from Certified RapidMiner Experts
  • abbaszavarabbaszavar Member Posts: 11 Contributor I

    Thank you Thomas,

    So how shoud define it?

     

    A

  • abbaszavarabbaszavar Member Posts: 11 Contributor I

    Thanks,

    My original DATE1 has "date format" such as (Jun 30,2015), so I don't think I need to change its format, do I?

    But when I follow the same format, it doesn't work again!

    if(date_diff(DATE1,Jun 30,2015)>7776000000,1,0)

     

    any advice?

    Thanks

    A

Sign In or Register to comment.