Amending an integer as a year to a date as a year

0
Good Evening,   We are storing a year in the an entity as an integer. I need to retrieve data for the year as the actual year. The year is entered as 2024, 2025 etc.   Is there a way of changing it in a microflow to the actual year from the integer.   Thanks in advance   Jess.
asked
1 answers
0

A year is a period of time, so you need it to be between 1st January 00:00:00 and 31st December 23:59:59 when you are querying.

 

To create the first date, assuming your year is stored as 4 digits such as 2025, you can use the following in a create variable action for a date. This will be the 1st of January for that year.

dateTime($year)

 

To create the second date, you can use the endOfYear function in a create variable action for date. This will be 31st December of that year.

endOfYear(dateTime($year))

 

https://docs.mendix.com/refguide/end-of-date-function-calls/#endOfYear

 

Now when you search, you need to look between the start of year and the end of year. 

[createDate >= $startofyear and createDate =< $endofyear]

 

I hope this makes sense and has helped. Good luck

answered