Get the current year

Hello team, I want to have the current year. I user the function today() but it give me the complete date like 2022-07-22. Now I need only the year. Your help please

You can use the form functions dealing with date and time. Combine the today() function with the format-date() function. See the documentation for more details: https://docs.getodk.org/form-operators-functions/#date-and-time

+-----------+-----------+--------------------------+---------------------------+
|   type    |   name    |          label           |        calculation        |
+-----------+-----------+--------------------------+---------------------------+
| calculate | calc_year |                          | format-date(today(),'%Y') |
| note      | show_year | The year is ${calc_year} |                           |
+-----------+-----------+--------------------------+---------------------------+
3 Likes

Thanks @danbjoseph it works

1 Like