dateFormat expression returns different year for december 31

Hello, greetings to all!

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

Expression structure:

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

Expression transform:

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 :sweat_smile:?

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 :face_with_monocle:.

Binding for copy and pasting
{
  "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!

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

2 Likes

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

Thank you very much!