Convert datetime using iconv, oconv

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Convert datetime using iconv, oconv

Post 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.
RD
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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]
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

Hi ArndW,

I am unable to see the full content.

Request you to please give the code
RD
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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####-##-## ##:##:##")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

Dear Ray,

Could you please give me code with date column as an example with the above timestamp format.
RD
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The code is in my response earlier.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply