Extract year from date and time

0
Hi everyone, I am new to mendix, I want to know How to extract only year from date & time? Thanks in advance.
asked
4 answers
2

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:)

answered
3

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.

answered
0

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

answered
0

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')
answered