In a document model we have:
- Field 1 is of Type “Date Time”, Field 2 is of Type “String”
We want to write the following computation:
- Field3 = Field1 + Field2 (like String concatenation)
Since these dont have the same type, SME complains. How to get the computation correct?
Hi @stefan-grey-canyon,
sadly the way to achieve this computation is not as straight forward as presented in your example. To display the DateTime value together with a string value in another string field you first have to deconstruct the date and time values to number fields by first spliting the DateTime-field in a Date-Field and Time-Field with the operator “DateFromDateTime” and “TimeFromDateTime”. Then you have to split the Date-field and Time-Field values further into Numberfields with the operators “DayFromDate”, “MonthFromDate”, “YearFromDate”, “HoursFromTime”, and “MinutesFromTime”. Now that all values have been converted to Numbers you can use them to build up your string concatenation with a computation that would look something like this:
[StringField2] + FieldValueAsString(DayField) + “.” + FieldValueAsString(MonthField) + “.” + FieldValueAsString(YearField) + “,” +FieldValueAsString(HourField)+ “:” +FieldValueAsString(MinutesField)
I hope this helps, for further information there is also a nice video of working with dates and times in our Monthly Modeling Highlights found in the mgm A12 wiki
This video is also available on getA12.com (link)