A program to recognize and reward our most engaged community members
date_str_custom(date, "MMM d, yyyy")date_str_custom(date, "hh:mm:ss a")
Hi,
I was looking for the same solution, the only thing is I need to present the month as "Nov" and not "11".
when I write 'date_str_custom(date, "yyyy/MM")' in generate new attribute operator I recieve the result as : 2017/11 but I need: 2017/Nov.
Then How can we define the final presentation of month in this context?
Thanks and regards,
Helena
Hi @helena_ahmadi,
A list of the available patterns can e.g. be found in the Help of the Operator Date to Nominal which is also available online on https://docs.rapidminer.com/latest/studio/operators/blending/attributes/types/date_to_nominal.html.
In your case you just need to add a "M" to your expression leading to date_str_custom(date, "yyyy/MMM").
In Generate Attributes you can also define which localization you want to use e.g. date_str_custom(date, "yyyy/MMM","us").
Happy Mining,
Edin
Hi @Edin_Klapic,
Thanks, it worked now.
Because I found this usefull when needing to generate date info, I thought I would put it here.
Generating a date and inserting into a feed.
<?xml version="1.0" encoding="UTF-8"?><process version="8.1.001"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="process" compatibility="8.1.001" expanded="true" name="Process"> <process expanded="true"> <operator activated="true" class="subprocess" compatibility="8.1.001" expanded="true" height="82" name=a"add date (2)" width="90" x="246" y="34"> <process expanded="true"> <operator activated="true" class="text:create_document" compatibility="8.1.000" expanded="true" height="68" name="open date (3)" width="90" x="514" y="34"> <parameter key="text" value=""content_date": ""/> </operator> <operator activated="true" class="text:create_document" compatibility="8.1.000" expanded="true" height="68" name="close date (3)" width="90" x="514" y="289"> <parameter key="text" value="", "/> </operator> <operator activated="true" class="generate_data_user_specification" compatibility="8.1.001" expanded="true" height="68" name="Generate Data by User Specification (2)" width="90" x="112" y="136"> <list key="attribute_values"> <parameter key="date_time" value="date_now()"/> </list> <list key="set_additional_roles"/> </operator> <operator activated="true" class="date_to_nominal" compatibility="8.1.001" expanded="true" height="82" name="Date to Nominal (2)" width="90" x="246" y="136"> <parameter key="attribute_name" value="date_time"/> <parameter key="date_format" value="yyyy-MM-dd'T'HH:mm:ss.SSSZ"/> <parameter key="locale" value="English (South Africa)"/> </operator> <operator activated="true" class="nominal_to_text" compatibility="8.1.001" expanded="true" height="82" name="Nominal to Text (2)" width="90" x="380" y="136"> <parameter key="attribute_filter_type" value="single"/> <parameter key="attribute" value="date_time"/> </operator> <operator activated="true" class="text:data_to_documents" compatibility="8.1.000" expanded="true" height="68" name="Data to Documents (3)" width="90" x="514" y="136"> <list key="specify_weights"/> </operator> <operator activated="true" class="text:combine_documents" compatibility="8.1.000" expanded="true" height="124" name="Combine Documents (4)" width="90" x="715" y="136"/> <connect from_op="open date (3)" from_port="output" to_op="Combine Documents (4)" to_port="documents 1"/> <connect from_op="close date (3)" from_port="output" to_op="Combine Documents (4)" to_port="documents 3"/> <connect from_op="Generate Data by User Specification (2)" from_port="output" to_op="Date to Nominal (2)" to_port="example set input"/> <connect from_op="Date to Nominal (2)" from_port="example set output" to_op="Nominal to Text (2)" to_port="example set input"/> <connect from_op="Nominal to Text (2)" from_port="example set output" to_op="Data to Documents (3)" to_port="example set"/> <connect from_op="Data to Documents (3)" from_port="documents" to_op="Combine Documents (4)" to_port="documents 2"/> <connect from_op="Combine Documents (4)" from_port="document" 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> <connect from_op="add date (2)" from_port="out 1" to_port="result 1"/> <portSpacing port="source_input 1" spacing="0"/> <portSpacing port="sink_result 1" spacing="0"/> <portSpacing port="sink_result 2" spacing="0"/> </process> </operator></process>