Page 1 of 1

Convert datetime using iconv, oconv

Posted: Fri Oct 11, 2013 2:51 am
by DSRajesh
Dear All

I am getting the datatime as YYYYMMDD_HHMMSS when using DSJ.JOBLASTTIMESTAMP in the routine.

I need to convert YYYYMMDD_HHMMSS to YYYY-MM-DD HH:MM:SS using iconv and oconv .

Can anyone please suggest me how to do this.

Posted: Fri Oct 11, 2013 3:21 am
by ArndW
There is no need to use ICONV() and OCONV() here, a simple string function works more efficiently:

Code: Select all

LastTS[1,4]:'-':LastTS[5,2]:'-':LastTS[7,2]:' ':LastTS[10,2]:':':LastTS[12,2]:':':LastTS[14,2]

Posted: Fri Oct 11, 2013 3:29 am
by DSRajesh
Hi ArndW,

I am unable to see the full content.

Request you to please give the code

Posted: Fri Oct 11, 2013 4:22 am
by ArndW
There should be enough visible to show you how to go about building the string correctly. The site is kept running by volunteers and by premium memberships and it would seem that the user ID you are using has let this lapse and for this reason the whole message is not visible to you.

Posted: Fri Oct 11, 2013 4:45 am
by ray.wurlod
I think that the substringing approach suggested by Arnd is probably more efficient, but wonder how close the following construction would be.

Code: Select all

Fmt(Convert("_","",LastTS),"L####-##-## ##:##:##")

Posted: Fri Oct 11, 2013 7:53 pm
by DSRajesh
Dear Ray,

Could you please give me code with date column as an example with the above timestamp format.

Posted: Sat Oct 12, 2013 2:31 pm
by ray.wurlod
The code is in my response earlier.