Hi,
The datetext function returns incorrect date with different locale settings. Please refer below:
datetext(ri!dateInput, "dd MMM YYY")
Input Date: 12/29/2021 - English/United states as locale -> 29 Dec 2022
Input Date: 29/12/2021 - English/United Kingdom as locale -> 29 Dec 2021 - this is correct.
The dateInput is sent as a rule input of type 'Date' to the expression rule.
Discussion posts and replies are publicly visible
weird !
here's an alternative if you need it
use: text(ri!date, "dd MMM YYYY")
I think datetext has a kind of bug. I played a bit with it.
a!localVariables( local!date: todate("12/29/2007"), a!formLayout( contents: { a!textfield( value: datetext(local!date, "dd MMM YYYY"), readOnly: true ) } ) ) -> until that date correct result a!localVariables( local!date: todate("12/29/2008"), a!formLayout( contents: { a!textfield( value: datetext(local!date, "dd MMM YYYY"), readOnly: true ) } ) ) -> 29 Dec 2009 until 2015-> 29 Dec 2016 a!localVariables( local!date: todate("12/29/2016"), a!formLayout( contents: { a!textfield( value: datetext(local!date, "dd MMM YYYY"), readOnly: true ) } ) ) -> 29 Dec 2016 until 2018-> 29 Dec 2018 a!localVariables( local!date: todate("12/29/2019"), a!formLayout( contents: { a!textfield( value: datetext(local!date, "dd MMM YYYY"), readOnly: true ) } ) ) -> 29 Dec 2020 and 2021 -> 29 Dec 2022 2022 is correct again. Not sure what the issue could be
yea, nice to play with this
I wrote this expression to analyse it from 1930 for the next 100 years
The years where it outputs wrong repeats in an order of 4,3,3,3,3,4,3,3,3,3,4,...
and similarly where it comes correctly are: 3,2,2,3,2,3,2,2,3,2,3,...
I wonder something gets messy due to leap years or so.....
Hope the screenshot highlight helps and hope Appian reads this post and can use it
a!localVariables( local!startYear: 1930, a!forEach( items: enumerate(2030 - local!startYear), expression: a!localVariables( local!date: "12/29/" & local!startYear + fv!index - 1, local!datetext: datetext(todate(local!date), "dd MMM YYYY"), local!text: text(todate(local!date), "dd MMM YYYY"), local!equal: local!datetext = local!text, "Input Date: " & local!date & " | Date Text Function: " & local!datetext & " | Text Function: " & local!text & " | Match: " & local!equal ) ) )