A date function that defaults a date field to the beginning of the year

Hi Kobo users,

I need help with creating a date field which automatically takes the first date of every year whenever a year changes to a new one.


Welcome to the community, @KOloo! Could you also provide more details on why you would like this? Wouldn’t today() fulfill your requirement?

Hi @Kal_Lam,
Thank you for your reply.

The today() function alone wouldn’t help me achieve what I want since it only returns the current date. I am building a tool for weekly data entry and I need to automatically calculate the number of weeks for which data is being submitted for the users of this tool from the first day of the year.

I am currently using int((today() - date(‘2022-01-01’)) div 7) to calculate this but the problem is that I will have to go back and change ‘2022-01-01’ at the start of every new year.