# dateFormat returning the wrong year

**URL:** <https://forum.inductiveautomation.com/t/dateformat-returning-the-wrong-year/100310>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [December 30, 2024, 5:37pm UTC](https://forum.inductiveautomation.com/t/dateformat-returning-the-wrong-year/100310 "2024-12-30T17:37:32Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 30, 2024, 8:45pm UTC](https://forum.inductiveautomation.com/t/dateformat-returning-the-wrong-year/100310/7 "2024-12-30T20:45:45Z")

</div>

Just to round this off a bit, `YYYY` returns the "week year", or the year that a week belongs to. (As far as I can make out) Week 1 contains the 1st January and since that's a Wednesday in 2025 the preceeding Monday and Tuesday are also in Week 1 of 2025. So (for my locale, Ireland), I get,  
`dateFormat(toDate("2024-12-29 08:00:00"), "YYYY")` → 2024  
`dateFormat(toDate("2024-12-30 08:00:00"), "YYYY")` → 2025  
`dateFormat(toDate("2024-12-31 08:00:00"), "YYYY")` → 2025  
`dateFormat(toDate("2025-01-01 08:00:00"), "YYYY")` → 2025

 ![YYYY year](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/c/ccdb612479fa70184d01f7d243d3cb0557bd8861.png)  
_Figure 1. Week 1 of 2025 contains the last two days of 2024, so the Week Year is 2025 for those two dates._

There's some discussion over on [StackOverflow](https://stackoverflow.com/a/56911450/3934992) which goes into some detail - but who has time?

---

_[View the full topic](https://forum.inductiveautomation.com/t/dateformat-returning-the-wrong-year/100310)._
