XML write of DATETIME field, includes milliseconds.

Posted by OctavioOlguin on 07-Nov-2017 10:21

Greetings.

Is there a way to avoid that WRITE-XML method includes milliseconds when exporting a datetime field?

currently getting 

Fecha="2017-11-07T10:17:27.431"

but laws ask for 

Fecha="2017-11-07T10:17:27"

TIA

Posted by Torben on 07-Nov-2017 11:35

Or make a procedure that changes the values to 0 for the millisecond part

dt = DATETIME(STRING(dt, "99/99/9999 HH:MM:SS")).

Posted by Peter Judge on 07-Nov-2017 10:34

WRITE-XML on a temp-table? I don’t think so.

You’ll have to write your own, using the SAX writer. You can see an example of that in github.com/.../PayloadBuilder.cls at line 171 (https://github.com/consultingwerk/ADE-Sourcecode/blob/964480c051b0c09a9b75bd02d8453afe5ab35b25/src/rules/OpenEdge/BusinessRules/PayloadBuilder.cls#L171 ), which manually formats a DATETIME field.
 
 
 
 

All Replies

Posted by Peter Judge on 07-Nov-2017 10:34

WRITE-XML on a temp-table? I don’t think so.

You’ll have to write your own, using the SAX writer. You can see an example of that in github.com/.../PayloadBuilder.cls at line 171 (https://github.com/consultingwerk/ADE-Sourcecode/blob/964480c051b0c09a9b75bd02d8453afe5ab35b25/src/rules/OpenEdge/BusinessRules/PayloadBuilder.cls#L171 ), which manually formats a DATETIME field.
 
 
 
 

Posted by Torben on 07-Nov-2017 11:35

Or make a procedure that changes the values to 0 for the millisecond part

dt = DATETIME(STRING(dt, "99/99/9999 HH:MM:SS")).

Posted by OctavioOlguin on 07-Nov-2017 13:13

But being the ISO 8601 format defined any number of decimal places for the lowest part of time incator, I think some optin to control that from 4gl, would be very welcome...

the current procedure I use to build XML, is very lengthy, and WRITE-XML allowed me to refactor heavily the code, and one class focused on data validation, uses 1 line of code to make the xml.... the current process uses several procedures, more than 4,000 lines to get the xml, and suporting tables. that a good class and WRITE-XML could do.

I'll fool it with a hidden node and a

XML-NODE-TYPE "ATTRIBUTE" SERIALIZE-NAME _original-name_    field to get the output needed.

then apply the tipo from [mention:c4bc59ca912947f48646dd9e9ff4acd5:e9ed411860ed4f2ba0265705b8793d05]

Thanks

This thread is closed