How to change the year of the date to current year

Hi all, I have a dates for example 01/02/2021, 01/02/2013, 12/02/2018 I just want to change year of that date to current year. 01/02/2021 = 01/02/2023 01/02/2013 = 01/02/2023 can anyone tell me how can I do this. Thanks
2 answers

An alternative to Tim's solution would be using formatDateTime functions:


  • formatDateTime($YourDate, ‘dd-MM’)
  • formatDateTime([%CurrentDateTime%], ‘yyyy’)
  • parseDateTime on the two steps above to make them into a single date again, so:
    parseDateTime(formatDateTime($YourDate, 'dd-MM') + '-' +  formatDateTime([%CurrentDateTime%], 'yyyy'), 'dd-MM-yyyy')


Note that I wrote these without opening the modeler so there may be some syntax errors, but the idea should remain the same. Also, if you want to let the time remain the same as well you'll have to add that to your expression.


Proof of it working:


addYears($YourDate, calendarYearsBetween($YourDate, [%CurrentDateTime%]))


**Editted to match your problem:

addYears($YourDate, calendarYearsBetween($YourDate, [%BeginOfCurrentYear%]))