Lets say your Enums are something like that:
notice the underscore in the Name. It is there as MX doesn’t allow Numbers as Names.
You could create a variable DateTimeStr
replaceAll(toString($ExcelReport/Year), '_', '') +
replaceAll(toString($ExcelReport/Month), '_', '-') + '-01'
The above will give you a parsable string to create the From DateAndTime. What it does is:
Then parse the DateTimeString to create the From DateAndTime variable like this:
parseDateTimeUTC($DateTimeStr, 'yyyy-MM-dd')
and to get the To DateAndTime create a variable as follows:
addDaysUTC(addMonthsUTC($DateTimeFrom, 1), -1)
then change the From and To attributes in your Object and you’re good to go.
Not sure how good is Javain your environment.
One approach is to crate a java_action passing the dates as parameters. Use the java 8 (java.time) API to manipulates the dates, and return the desired results. The Java action can be expended further, to use a custom class, with static methods.
Have designed a date time utility using the time API. However, was for different purpose, such as calculating a future date and time for a running task, running at different intervals.
Yes I applied this method but it gives me an error:
I tried with replaceall but it still doesn’t work.
Its giving me this error when I parse it into integer.
com.mendix.core.CoreException: com.mendix.modules.microflowengine.MicroflowException: Failed to evaluate expression, error occurred on line 1, character 1
parseInteger($ConvertYearIntoString)
^
at Common.SUB_SetToAndFrom (CreateOrChangeVariable : 'Create Integer/Long variable')
at Common.ACT_Process_Enhanced (SubMicroflow : 'SUB_SetToAndFrom')
Advanced stacktrace:
at com.mendix.basis.component.InternalCoreBase.execute(InternalCoreBase.java:389)
Caused by: com.mendix.modules.microflowengine.MicroflowException: Failed to evaluate expression, error occurred on line 1, character 1
parseInteger($ConvertYearIntoString)
^
at Common.SUB_SetToAndFrom (CreateOrChangeVariable : 'Create Integer/Long variable')
at Common.ACT_Process_Enhanced (SubMicroflow : 'SUB_SetToAndFrom')
Advanced stacktrace:
at com.mendix.languages.mxexpressions.MxExpression.evaluate(MxExpression.scala:21)
Caused by: com.mendix.languages.expressions.ExpressionException: java.lang.NumberFormatException: For input string: "01-Jan-2019 12:00:00 AM"
at com.mendix.languages.expressions.Expr.evaluate(Expr.java:34)
I got the values. Thank you so much for the help :)