toDate('Y') outputs only actual year

I am getting ‘2022’ on all toDate(‘Y’) calls. This is my blueprint:

          datestart:
            label: Date
            type: number
          ongoing:
            label: Ongoing ?
            type: toggle
            text:
              - "no"
              - "yes"
          dateend: 
            label: End date
            type: number
            when:
              ongoing: false

This is a content file example

Datestart: 2020

----

Ongoing: false

----

Dateend: 2021

This is my template code :

    <div class="content-work-date">
        <?= $work->datestart()->isNotEmpty() ? $work->datestart()->toDate('Y') : 'n.d.'?>
        <?= $work->ongoing()->toBool() ? ' - ongoing' : '' ?>
        <?= $work->dateend()->isNotEmpty() ? ' - ' . $work->dateend()->toDate('Y') : '' ?>
    </div>

And this is output :woman_shrugging:

2022 - 2022

It looks as if I was doing the typical mistake of calling my date field “date”, and so actually making a new date in the process instead of retrieving that in the field. But I can’t see how am I doing this.

Possibly a stupid mistake, apologies in advance.

Thank you

Since the content only contains a year, why are you even calling toDate() on a non-date instead of just outputting the field value?

Ah you’re right, that is a ‘number’ field, not a ‘date’ field.

As expected, a silly mistake!

Thank you