SXI Forum

A place to collect usefull tips, tricks and implementation strategies.

You are not logged in.

#1 27-12-2018 14:48:26

StephanB
Member
Registered: 21-11-2018
Posts: 39

Converting a Date Time stamp

I need some help on covering the fallowing Date Time stamp from 24 December 2018 7:52 AM to 2018/12/24 07:52:00.

Offline

#2 28-12-2018 08:24:36

SeanR
Administrator
Registered: 20-11-2018
Posts: 148

Re: Converting a Date Time stamp

Hi Steph,

This is untested however it should work.  I got the date format rules for SimpleDateFormat from here.  Specifically look at "Pattern Syntax" and "Pattern Examples" on that page.

    <sxi:DataDefinition name="ConvertDate">
      <sxi:Fields>
        <sxi:Field name="InDate">
          <sxi:Rules>
            <sxi:DateConverter InputDateFormat="dd MMMM yyyy h:mm a" OutputDateFormat="yyyy/MM/DD HH:MM:ss"/>
          </sxi:Rules>
          <sxi:OutputField>OutDate</sxi:OutputField>
        </sxi:Field>
      </sxi:Fields>
    </sxi:DataDefinition>

Not sure how you are going to get the seconds as they are not provided in the input example you gave.

Ciao
Sean

Offline

#3 29-12-2018 11:15:58

StephanB
Member
Registered: 21-11-2018
Posts: 39

Re: Converting a Date Time stamp

Hi Sean,
There is no input for the seconds, I will test it and let you know.
Thx.

Offline

#4 29-12-2018 11:53:50

StephanB
Member
Registered: 21-11-2018
Posts: 39

Re: Converting a Date Time stamp

It's working correct with this Date Converter rule, I changed the Output Date Format to "yyyyy/MM/dd HH:mm:ss".
The seconds are not provided in the input, it will default to "00".

          <sxi:Rules>
            <sxi:DateConverter InputDateFormat="dd MMMM yyyy h:mm a" OutputDateFormat="yyyy/MM/dd HH:mm:ss"/>
          </sxi:Rules>

I have tested the AM / PM .
Tested with Input "24 December 2018 7:52 PM"
Output ----------- <DateTime>2018/12/24 19:52:00</DateTime>

Tested with input "24 December 2018 7:52 AM"
Output ----------- <DateTime>2018/12/24 07:52:00</DateTime>

Last edited by StephanB (30-12-2018 14:35:59)

Offline

Board footer

Powered by FluxBB