[✅ Solution] Getting the current year

I feel like this should be very simple but I’ve tried every current_date token I could get my hands on, along with hardcoded values but I keep getting the below error. Any guidance would be greatly appreciated.

Tapes documentation shows this:

Im trying:

But I keep getting this error:

console.log(date_fns.format(date_fns.parseISO(current_datetime_formatted), 'y'));
console.log(date_fns.format(new Date(), 'y'));
console.log(date_fns.format(date_fns.parseISO(current_date_utc), 'y'));

In a calculation field:

2 Likes

Thank you. That did it of course! :raised_hands:

2 Likes

does this auto updates to the next date, month, year? Unlike the moment() which does not auto updates to current date?

@Sameer I am not really sure what you mean to my knowlage both moment and date_fns will calculate/format the date they are given at the time they are ask to perform the task.

The calculation field example uses the created on date and this obviously never changes in one of the automation examples it uses new Date() this will give the current date at time of formatting/calculation so if you perform the calculation day 1 and then on day 30 the results will be different.

Now I think what you are asking is if you had a calculation field in Tape with say:

date_fns.format(new Date(), 'y'))

what the year automatically display 2026 rather than 2025 on the 1st Jan 2026 and the answer to that is no not unless you trigger the calculation field on that record. There is a thread about it here: Calculation with today

If thats not what you are asking let me know and I will try again

2 Likes