How can i substract a 1 month to a example that is a date?
Find more posts tagged with
Sort by:
1 - 4 of
41
@cdaponte, You could use the date_get function for this (under generate attributes). This allows you the get the month value for the current date and the 'older' date, and as these are numeric (0 to 11) you could simple calculate the difference (in months)
As in attached example : I used two (generated) dates, one is now and the other is like 2 months ago (50 days difference). this gives a number for each month (be aware that for some strange reason month numbers start with 0 for January instead of 1)
As in attached example : I used two (generated) dates, one is now and the other is like 2 months ago (50 days difference). this gives a number for each month (be aware that for some strange reason month numbers start with 0 for January instead of 1)
<?xml version="1.0" encoding="UTF-8"?><process version="9.3.001"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="process" compatibility="9.3.001" expanded="true" name="Process"> <parameter key="logverbosity" value="init"/> <parameter key="random_seed" value="2001"/> <parameter key="send_mail" value="never"/> <parameter key="notification_email" value=""/> <parameter key="process_duration_for_mail" value="30"/> <parameter key="encoding" value="UTF-8"/> <process expanded="true"> <operator activated="true" class="generate_macro" compatibility="9.3.001" expanded="true" height="82" name="Generate Macro" width="90" x="313" y="34"> <list key="function_descriptions"> <parameter key="MonthNow" value="date_get(date_now(),DATE_UNIT_MONTH)+1"/> <parameter key="MonthOld" value="date_get(date_add(date_now(),-50,DATE_UNIT_DAY),DATE_UNIT_MONTH)+1"/> </list> </operator> <connect from_port="input 1" to_op="Generate Macro" to_port="through 1"/> <connect from_op="Generate Macro" from_port="through 1" to_port="result 1"/> <portSpacing port="source_input 1" spacing="0"/> <portSpacing port="source_input 2" spacing="0"/> <portSpacing port="sink_result 1" spacing="0"/> <portSpacing port="sink_result 2" spacing="0"/> <description align="center" color="yellow" colored="false" height="50" resized="true" width="177" x="268" y="134">January = month 0</description> </process> </operator> </process>
Sort by:
1 - 2 of
21
There are many ways to accomplish this in RapidMiner. If your attributes are defined as date/time types, then one way would be use the datediff function inside Generate Attributes and simply convert from milliseconds to months (and then potentially round that number in some way).
Another way would be to use Date to Numerical to get the month number of your date/time stamps and then do ordinary subtraction (with an adjustment to handle the possible negative values).
Another way would be to use Date to Numerical to get the month number of your date/time stamps and then do ordinary subtraction (with an adjustment to handle the possible negative values).
Another way would be to use Date to Numerical to get the month number of your date/time stamps and then do ordinary subtraction (with an adjustment to handle the possible negative values).