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
[SOLVED] Using date-values in context
Mario_Hofmann
Member Posts: 9 Contributor II
Hello,
I ve got a question regarding the usage of dates in the context. I set a macro startdate e.g. as "2012-12-01" in a macro.
When I want to calculate the difference to a date in an example set I m not able to convert the variable in a valid time string. Using date_parse_custom(%{startdate},"yyyy-MM-dd","de") does not work and gives me only errors.
I created a workaround by setting multiple macros for each year, month and day and reset the current date. There I encountered the problem that the month adds 1 month to the current date. E.g. date_set(date_now(),"12",DATE_UNIT_MONTH) returns 2013-01-014.
Thanks for any advice!
Regards,
Mario
I ve got a question regarding the usage of dates in the context. I set a macro startdate e.g. as "2012-12-01" in a macro.
When I want to calculate the difference to a date in an example set I m not able to convert the variable in a valid time string. Using date_parse_custom(%{startdate},"yyyy-MM-dd","de") does not work and gives me only errors.
I created a workaround by setting multiple macros for each year, month and day and reset the current date. There I encountered the problem that the month adds 1 month to the current date. E.g. date_set(date_now(),"12",DATE_UNIT_MONTH) returns 2013-01-014.
Thanks for any advice!
Regards,
Mario
0
Answers
nice to see that you are actually using RapidMiner!
Please remember that the macro is replaced *before* the actual evaluation of the expression. That means that you have to surround it with quotes in this case. Please have a look at the attached process for a working example.
Best!
Marius
perhaps you only missed to quote the macro in ?
I have attached an example process in which I used the date in the context to calculate the elapsed time between 2 dates.
Please keep in mind that the results represents the time in ms and you have to convert it afterwards (e.g. by dividing it by 86 400 000 to get the time in days ).
Hope that helps!
Best,
Edin
Thank you!