Skip to main content
October 5, 2022
Solved

Why my ER is taking wrong value of date.

  • October 5, 2022
  • 8 replies
  • 0 views

Hi all,

I am trying to take a date value from a DB(which I am writing in the Expression value below) and once I am inputting it in rule input it is changing my date value(Refer Value field):

 

Can anyone guide me what I am doing wrong, I need 03/10/22 as an output.

Thank you.

    Best answer by gabriele.camilli

    Hi,

    If it's consistent just use

    todate(
    joinarray(
    reverse(
    split(ri!date,"-")
    ),
    "/"
    )
    )

    I guess that the DB column it's string so note that ri!date should be of type text

    8 replies

    shalinim0003
    October 5, 2022

    Use todate("03-10-2022")

    maryl0003Author
    October 5, 2022

    Thanks Shalini, but how can we convert "2022-10-03" that is coming from database to "03-10-2022" ?

    gabriele.camilli
    October 5, 2022

    Hi,

    If it's consistent just use

    todate(
    joinarray(
    reverse(
    split(ri!date,"-")
    ),
    "/"
    )
    )

    I guess that the DB column it's string so note that ri!date should be of type text

    mikes0011
    Brainy
    October 5, 2022

    The exact expression `2022-10-03` (note no quotation marks etc) will evaluate as a math operation, i.e. "2022 minus 10 minus 3", and return an integer value, which Appian will try to interpret as a date (and of course will be very wrong).

    Note that if your DB columns are set to the "Date" data type, they will be displayed there as YYYY-MM-DD formatting, however this is just the display mode.  Appian will actually receive a proper "date" data type when querying the data from the DB, which in Appian will display with the default Appian date formatting.  There should be no need (assuming the date is stored in the DB as a date and not as text) to have to play with manually parsing the value back into a Date from a YYYY-MM-DD formatted text string.

    The Expression Guru
    maryl0003Author
    October 5, 2022

    Exactly!

    Thank you Mike, I got confused a bit in that in the start.