mendix Year calculation

0
  I want to get current year so I am using formatDateTime([%CurrentDateTime%],'YYYY'); It was working fine 2 days back but for the last two days, it is returning ‘2022’ instead of ‘2021’. Can any body help  
asked
1 answers
3

You are using the wrong format for year.

‘YYYY’ is the week year, you need to use ‘yyyy’ which is the year for the current datetime.
 

formatDateTime([%CurrentDateTime%],'yyyy');


Behind the scenes Mendix is using Java’s SimpleDateFormat, more details on the formatting string can be found in its documentation.

https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/SimpleDateFormat.html

Hope this helps

answered