The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

Calculating time difference in days between two dates

felix_wfelix_w Member Posts: 61 Contributor II
edited November 2018 in Help

Dear Rapidminer Community, 

 

I am struggling on a very simple problem. I am trying to calculate the difference in days between two dates. I know there is a function called "date_diff" in generate attributes but I dont know how to enter a correct date. 

 

No I don't have the two dates in seperate columns, I only have the date in the above format in one column and I know the end date (24.12.2016). 

 

E.g. I want to calculate the date difference between 25.08.2016 and 24.12.2016 (German date format). How do I enter a correct format like this in rapidminer in the date_diff function? 

 

Best regards

Felix

Best Answer

  • MartinLiebigMartinLiebig Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,533 RM Data Scientist
    Solution Accepted

    Hi @felix_w,

    it works like that:

    date_diff(dateAttribute,date_parse_custom("24.12.2016","dd.MM.yyyy"))

    note that you can get the current timestamp with date_now().

     

    Best,

    Martin

    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany

Answers

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

    And just remember that date_diff function will return results in milliseconds so if you want to convert to another time unit (like days) you'll need to divide the result by the appropriate number.

    Brian T.
    Lindon Ventures 
    Data Science Consulting from Certified RapidMiner Experts
  • felix_wfelix_w Member Posts: 61 Contributor II

    Thank you Martin! Having different date formats all around the world really sucks ^^ 

     

    Best regards

    Felix

  • MartinLiebigMartinLiebig Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,533 RM Data Scientist

    Hi @felix_w,

    right. But as long as you don't have DD-MM-YYYY and MM-DD-YYYY in ONE document/example set everything is good. And yes, this exists :(

     

    Best,

    Martin

    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
Sign In or Register to comment.