datetext() appears to increment the year if it's used December27 -December 31st

Noticed something strange when using the datetext() function on dates near the end of December.  Using datetext() on dates December 27th or later display the next year rather than the correct one.  Example below...

a!localVariables(

  local!dateDec25th: date(2021, 12, 25),
  local!dateDec27th: date(2021, 12, 27),

  {
    dateDec25th: local!dateDec25th,
    dateText25th: datetext(local!dateDec25th, "M/d/YYYY"),
    gmtThe25th: datetext(gmt(local!dateDec25th), "M/d/YYYY"),
    a: "********",
    dateDec27th: local!dateDec27th,
    dateText27th: datetext(local!dateDec27th, "M/d/YYYY"),
    gmtThe27th: datetext(gmt(local!dateDec27th), "M/d/YYYY"),
    aa: "********",
    toDate25th: todate(local!dateDec25th),
    toDate27th: todate(local!dateDec27th),
    gmt: todate(gmt(local!dateDec27th))

  }

  /**** 
  The above returns...

  dateDec25th:  12/25/2021(Date)
  dateText25th: "12/25/2021"(Text)
  "********"
  dateDec27th:  12/27/2021(Date)
  dateText27th: "12/26/2022"(Text)
  "********"
  toDate25th: 12/25/2021(Date with Timezone)
  toDate27th: 12/27/2021(Date with Timezone)

  ****/

)

Am I using the datetext() function incorrectly?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Confirmed this behavior occurs for me in my 22.1 environment.  Good catch. I'd recommend opening a support case with Appian to serve as an official Bug Report.I don't use dateText() very much because I usually find text() serves my purposes (and i use a custom expression rule with text() but wrapped in a null-checker, i.e. rule!GLBL_saveText()).

    Edit: i just noticed the "format" parameter in the dateText function instructions say to write the year as "yyyy", while yours are uppercase.  If you convert your "YYYY"s to lower case it appears to work.  From the documentation, it looks as if upper-case "Y" is used to indicate a special case called "Week Year".  This is the first I've heard of that but it looks as if it explains the quirk you've encountered.

Reply
  • 0
    Certified Lead Developer

    Confirmed this behavior occurs for me in my 22.1 environment.  Good catch. I'd recommend opening a support case with Appian to serve as an official Bug Report.I don't use dateText() very much because I usually find text() serves my purposes (and i use a custom expression rule with text() but wrapped in a null-checker, i.e. rule!GLBL_saveText()).

    Edit: i just noticed the "format" parameter in the dateText function instructions say to write the year as "yyyy", while yours are uppercase.  If you convert your "YYYY"s to lower case it appears to work.  From the documentation, it looks as if upper-case "Y" is used to indicate a special case called "Week Year".  This is the first I've heard of that but it looks as if it explains the quirk you've encountered.

Children