Ankündigung

Einklappen
Keine Ankündigung bisher.

Can't parse date from String

Einklappen
X

Can't parse date from String

Einklappen
  • Filter
  • Zeit
Alles löschen
neue Beiträge

  • Can't parse date from String

    Hello Intrexx community,

    I am not sure if this topic is already here, but I am having problems with parsing String values to date.

    I have a 2 edit field elements set do Date with this format ("16/12/2021"), (date From and dateTo).
    I have a button with JS on it, which should take those values and send them throguh JSON, but from there I am not able to parse string to date in groovy, I've tried several methods but all of them failed with parseerror message in the browser with no error message in it, So I don't know at which point I am making a mistake.

    Next step in my code should be a SQL select within range of those Dates, but I cannot do this select with string value.
    I've tried several forums and bits of code, but none worked for me, so maybe you've came acros this issue in the past.

    Thank you

    Kind regards,
    Patrik

  • #2
    Hi Patrik,

    make sure to format the Date to a universal format like ISO.
    In Groovy (and also JS) you can use the SimpleDateFormat to parse it to a Date.

    I hope this helps you to solve this issue :-)

    Martin

    Kommentar


    • #3
      Or you can comfortably work with groovy.sql.Sql. Sorry, I don't have more time right now than for this one-liner:
      Code:
      def records = new groovy.sql.Sql(g_dbConnections.systemConnection).rows("select * from XDATAGROUP8456212E1 where DTINSERT > ? and DTINSERT < ?", ["16/12/2021", "31/12/2021"])

      Kommentar


      • #4
        Hello,

        Sorry for long reply and thank you both for your posts.
        I've tried the first method with some addition and it worked in the end.

        Thank you

        Kind regards,
        Patrik

        Kommentar

        Lädt...
        X