How to extract month from DateTime and divide by 12?

0
Hello everyone,I’m trying to use MENIDX to extract the month from a DateTime field (e.g. $Measure/IsDate_II_4) and divide it by 12 to get a fractional value. I’ve already tried the following: / → error: “The '/' part is incomplete or incorrect” div() → not recognized month() → unknown function My goal is something like: $Measure/AK_Shift * $Measure/Shift_modelcurrentyear * (Month(IsDate_II_4) / 12) Does anyone know which function or syntax is correct in M3 for this?👉 extract the month as a number👉 valid division Thanks 🙏
asked
2 answers
1

Hi Ronald,

 

You can use the formatDateTime function to get the month from a date.  

Document link: https://docs.mendix.com/refguide/parse-and-format-date-function-calls/

 formatDateTime($YourDateVariable, 'MM') returns the month number as a string, e.g., '10' for October.    

parseInteger(formatDateTime($YourDateVariable, 'MM')) returns the month as an integer from 1 to 12.

answered
0

Have a look at the Parse and Format Date function calls in the Mendix documentation here; e.g. parseInteger(formatDateTime($yourDateTime, 'M')); Mendix uses the SimpleDateFormat, so you can find Date and Time patterns here.

You must use : instead of / for divisions as / is reserved for object/member navigation. Or use the div operator instead such as $value1 div $value2 which equals $value1 : $value2

answered