Hello harsha you can use fomatDateTime($employee/year,YYYY) function as a string variable or parseInteger(formatDateTime($emp/year,'YYYY') if needed in int/long. Hope it helps:)
You can use the formatDateTime function to return just the year as a String.
formatDateTime($object/Date1,'yyyy')
https://docs.mendix.com/refguide/parse-and-format-date-function-calls/#3-formatdatetimeutc
I hope this helps.
Hi Harsha
Use formatDateTime function, the format should be ‘yyyy’ to get only year from the date:
https://docs.mendix.com/refguide7/parse-and-format-date-function-calls/#formatdatetimeutc
Regards,
Anahit
Hi Harsha,
You can take Year from DateTime Object in Different ways. it Depends on the requirement where you need it. If You need to perform any operation on the variable then you can use the Solution 1 else you can Use Solution 2 for xPath constraints.
Solution1 :
formatDateTime($object/Date1,'yyyy')
Solution 2:
year-from-dateTime ( attribute [, timezone ] )
year-from-dateTime(DateAttribute, 'America/New_York')