# dateFormat expression returns different year for december 31

**URL:** <https://forum.inductiveautomation.com/t/dateformat-expression-returns-different-year-for-december-31/84282>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [January 15, 2024, 7:12pm UTC](https://forum.inductiveautomation.com/t/dateformat-expression-returns-different-year-for-december-31/84282 "2024-01-15T19:12:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlosbqz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carlosbqz/32/52324_2.png) [@carlosbqz](https://forum.inductiveautomation.com/u/carlosbqz)\
**Post date:** [January 15, 2024, 7:12pm UTC](https://forum.inductiveautomation.com/t/dateformat-expression-returns-different-year-for-december-31/84282/1 "2024-01-15T19:12:08Z")

</div>

Hello, greetings to all!

I am having an issue where I am using the following ignition expression:

Expression structure:

```auto
{value}["Year"] = 2023
{value}["Month"] = 11
{value}["Day"] = 31

```

Expression transform:

```auto
dateFormat(getDate({value}["Year"],{value}["Month"],{value}["Day"]), "dd-MMM-YY")

```

The value that I am expecting to be returned is `31-Dec-23` but it is returning `31-Dec-24`, any ideas of why is it behaving like this 😅?

The getDate expression is working just fine, the issue comes from dateFormat, I tried using the format `yyyy-MM-dd` and returns `2023-12-31` as expected 🧐.

> **Binding for copy and pasting**
>
> ```auto
> {
> "type": "expr-struct",
> "config": {
> "struct": {
> "Year": 2023,
> "Month": 11,
> "Day": 31
> },
> "waitOnAll": true
> },
> "transforms": [
> {
> "expression": "dateFormat(getDate({value}[\"Year\"],{value}[\"Month\"],{value}[\"Day\"]), \"dd-MMM-YY\")",
> "type": "expression"
> }
> ]
> }
> 
> ```

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 15, 2024, 7:14pm UTC](https://forum.inductiveautomation.com/t/dateformat-expression-returns-different-year-for-december-31/84282/2 "2024-01-15T19:14:05Z")

</div>

Capital `Y` has a different meaning than lower-case `y` in date formats. You are experiencing documented behavior.

---

<div class="post-metadata">

**Author:** ![carlosbqz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carlosbqz/32/52324_2.png) [@carlosbqz](https://forum.inductiveautomation.com/u/carlosbqz)\
**Post date:** [January 15, 2024, 7:20pm UTC](https://forum.inductiveautomation.com/t/dateformat-expression-returns-different-year-for-december-31/84282/3 "2024-01-15T19:20:58Z")

</div>

Wow, that's embarrassing, I didn't think about that.

Thank you very much!
