extract year from birth date in microflow

0
Hello,   I would like to extract only the year from a birthdate which is collected from a registration form to a db so i created a microflow with a  retrieve list object and a loop function. what i am missing is the object type that should go inside the loop function for this and also what constraint (if any) should i enter for that.   Thanks.  
asked
5 answers
1

Use activity “Change object” using entity “IteratorCustomer” and set attribute “Year” to value parseInteger(formatDateTime($IteratorCustomer/dateofbirth, ‘yyyy’))

parseInteger(formatDateTime($IteratorCustomer/dateofbirth, ‘yyyy’))

** Edited ** replaced formatDate with format DateTime, replaced Dateofbirth  with dateofbirth and replaced “yyyy” with ‘yyyy’

answered
0

Thanks for the answer.

i am getting an error message , maybe i did something wrong. please see image below.

 

answered
0

You have an error because you are using double quote (“) instead of simple quote(‘)

answered
0

correct.

i fixed the typo and it show an error “invalid argument types(Date and Time , string) function format date expect a a”date and time).

but when i look at the attribute type of dateofbirth in the domain model it is already set to date and time.

see image below.

answered
0

The function call should read parseInteger(formatDate($IteratorCustomer/dateofbirth, “yyyy”))  → note the lower case d.  Mendix is case sensitive and looking at your domain model, the attribute name is all lower case.

Also, an alternative way to do this is with the Java Action GetIntFromDateTime from Community Commons.  Add this Java action to your microflow and configure it with the date and the part of the date you want as an integer (month, day or year)

answered