The RapidMiner community is on read-only mode until further notice. Technical support via cases will continue to work as is. For any urgent licensing related requests from Students/Faculty members, please use the Altair academic forum here.

# Converting Numerical Date back to Date Format

Member Posts: 1 Learner I
Hello community! Sorry for bothering with my Newbie-Question!

My problem:
I have missing values for a certain date attribute -Date1- that I want to fill up. It's actually quite easy, because I have two other attributes that will help me calculate the missing values. So there's a numeric attribute like -DaysUntil- and the other Date -Date2-. I have Date2 and -DaysUntil-, so

Date2 - DaysUntil

would give me my Date1 that I need.

As I said, -DaysUntil- is numeric, like 10 for example, and Date2 a date value. I can't calculate with those formats, so I already used the Date to Numeric Operator to get a numeric value for my Date2. I used day in the epoch. So now what I can do is to just substract the numeric values like given above, but that leaves me with a numeric value (day in epoch) for my Date1. (I need Date1 as a Date format though)
The Numeric to Date Operator doesn't work for this kind of 'back conversion'.

So how do I get my Date1 as a Date format value now?
Or should I use a different Operator for calculation in the first place?

Tagged:

• Member Posts: 191 Unicorn
Hi,

You should be able to use a single operator to solve this problem. I used generate attributes with the following formula: if(missing([Date1]), date_add([Date2],-[DaysUntil],DATE_UNIT_DAY,"UTC"), [Date1])

I've also attached an example process. Any questions, please let me know.

Best,
Roland

```<?xml version="1.0" encoding="UTF-8"?><process version="10.3.000">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="10.3.000" expanded="true" name="Process">
<parameter key="logverbosity" value="init"/>
<parameter key="random_seed" value="2001"/>
<parameter key="send_mail" value="never"/>
<parameter key="process_duration_for_mail" value="30"/>
<parameter key="encoding" value="UTF-8"/>
<process expanded="true">
<operator activated="true" class="subprocess" compatibility="10.3.000" expanded="true" height="82" name="Generate demo data" width="90" x="45" y="34">
<process expanded="true">
<operator activated="true" class="utility:create_exampleset" compatibility="10.3.000" expanded="true" height="68" name="Create ExampleSet" width="90" x="45" y="34">
<parameter key="generator_type" value="comma separated text"/>
<parameter key="number_of_examples" value="3"/>
<parameter key="use_stepsize" value="false"/>
<list key="function_descriptions"/>
<list key="numeric_series_configuration"/>
<list key="date_series_configuration"/>
<list key="date_series_configuration (interval)"/>
<parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/>
<parameter key="time_zone" value="SYSTEM"/>
<parameter key="input_csv_text" value="Date1,DaysUntil,Date2&#10;1/1/23, 10, 11/1/23&#10;2/1/23, 10, 12/1/23&#10;3/1/23, 10, 13/1/23"/>
<parameter key="column_separator" value=","/>
<parameter key="parse_all_as_nominal" value="false"/>
<parameter key="decimal_point_character" value="."/>
<parameter key="trim_attribute_names" value="true"/>
</operator>
<operator activated="true" class="nominal_to_date" compatibility="10.3.000" expanded="true" height="82" name="Nominal to Date" width="90" x="179" y="34">
<parameter key="attribute_name" value="Date1"/>
<parameter key="date_type" value="date"/>
<parameter key="date_format" value="DD/MM/yy"/>
<parameter key="time_zone" value="SYSTEM"/>
<parameter key="locale" value="English (United States)"/>
<parameter key="keep_old_attribute" value="false"/>
</operator>
<operator activated="true" class="nominal_to_date" compatibility="10.3.000" expanded="true" height="82" name="Nominal to Date (2)" width="90" x="313" y="34">
<parameter key="attribute_name" value="Date2"/>
<parameter key="date_type" value="date"/>
<parameter key="date_format" value="DD/MM/yy"/>
<parameter key="time_zone" value="SYSTEM"/>
<parameter key="locale" value="English (United States)"/>
<parameter key="keep_old_attribute" value="false"/>
</operator>
<operator activated="true" class="blending:generate_columns" compatibility="10.3.000" expanded="true" height="82" name="Generate Attributes" width="90" x="447" y="34">
<list key="function_descriptions">
<parameter key="Date1" value="if(row_number()==2, MISSING_DATE_TIME, [Date1])"/>
</list>
<parameter key="keep_all_columns" value="true"/>
</operator>
<connect from_op="Create ExampleSet" from_port="output" to_op="Nominal to Date" to_port="example set input"/>
<connect from_op="Nominal to Date" from_port="example set output" to_op="Nominal to Date (2)" to_port="example set input"/>
<connect from_op="Nominal to Date (2)" from_port="example set output" to_op="Generate Attributes" to_port="table input"/>
<connect from_op="Generate Attributes" from_port="table output" to_port="out 1"/>
<portSpacing port="source_in 1" spacing="0"/>
<portSpacing port="sink_out 1" spacing="0"/>
<portSpacing port="sink_out 2" spacing="0"/>
</process>
</operator>
<operator activated="true" class="blending:generate_columns" compatibility="10.3.000" expanded="true" height="82" name="Generate Attributes (2)" width="90" x="179" y="34">
<list key="function_descriptions">