data format conversion

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
dsscholar
Premium Member
Premium Member
Posts: 195
Joined: Thu Oct 19, 2006 2:45 pm

data format conversion

Post by dsscholar »

Hi all,

I have a varchar column coming the source(ds) which needs to be converted to date (target oracle's default date format).

Format eg : 11 jun 2011 11 : 30

This needs to be converted to oracle's standard date format. I tried in transformer using stringtodate(inputcolumn,'%yyyy-%mm-%dd'). I gives minimum characters in the required year place something like that. I understand that the format is wrong. Please help in this conversion..

Thanks in advance.
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Will you be loading an Oracle table using DataStage? If so, tackle the task of converting the string into a Date datatype within DataStage first (well, do that anyway :) ). StringToDate() function in the parallel transformer would be an appropriate starting point.

If you're loading the table with a DataStage job and the date is stored as an Oracle Date datatype, DataStage will handle the conversion from DS Date (or Timestamp if you prefer) to Oracle Date automatically and you don't need to worry about formatting it for Oracle (dates and databases have been discussed many times here).

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Make sure you understand how StringToDate works. A date is a date, so you need to describe what format the incoming string is in, not what you think the date needs to look like.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Perhaps StringToTimestamp() should be the function you are using. The StringToDate() function has day granularity.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dsscholar
Premium Member
Premium Member
Posts: 195
Joined: Thu Oct 19, 2006 2:45 pm

Post by dsscholar »

As mentioned, i tried with StringToDate(UStringToString(lnk_scAuditKey.timestamp),'%dd %mon %yyyy'). Input format is 30 jul 2011 11:30. I tried with StringToTimestamp also. in the format of '%dd %mmm %yyyy %hh : %mm : %ss'. But that also not working.

Error
: Data string '30 Jun 2011 ' does not match format '%dd %mon %yyyy': an integer was expected to match tag %m.
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Post by SURA »

Use as Ray said. Hence you have time in the date, you should go for timestamp too.

DS User
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

%mon is not a valid date format token. All of the valid tokens may be found in the documentation (manuals or Information Center).
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