Date 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
balu124
Participant
Posts: 49
Joined: Wed Jul 25, 2007 9:53 pm

Date conversion

Post by balu124 »

Hi ,

I am getting the data from sequential file,in that the data for the date column is in the format of dd-mon-yyyy(Ex 29-sep-07).

I need to extract month number and month name from it .
fro extracting date and year I useed left() ,Right() . How to get the substring of thedate field.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

In a transform stage you can use the derivation "In.DateColumn[4,3]" to get "sep" from "29-sep-07"
balu124
Participant
Posts: 49
Joined: Wed Jul 25, 2007 9:53 pm

Post by balu124 »

ArndW wrote:In a transform stage you can use the derivation "In.DateColumn[4,3]" to get "sep" from "29-sep-07" ...
Hi Arndw,
I used the derivation as "DSLink17.CALL_DATE(4,3)" I got the output as DSL. (DSLink is the name of the input link and the call_date is the name of the column)

I used the derivation as "In.DSLink.Call_date[4,3]" I got the output as In.

Can you please lookinto this....
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post by Maveric »

Copy Paste your exact derivation here. You can use the field() function. Field(input Date field name,"-" ,2) will give you "sep" as the output.
balu124
Participant
Posts: 49
Joined: Wed Jul 25, 2007 9:53 pm

Post by balu124 »

Maveric wrote:Copy Paste your exact derivation here. You can use the field() function. Field(input Date field name,"-" ,2) will give you "sep" as the output.
Hi Maveric
May I know where the field function available ( I mean under date functions or string functions....)
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

balu124 - you need to use DSLink17.Call_date[4,3]
balu124
Participant
Posts: 49
Joined: Wed Jul 25, 2007 9:53 pm

Post by balu124 »

ArndW wrote:balu124 - you need to use DSLink17.Call_date[4,3] ...
Hi Arndw,
I used the same DSLink17.Call_date[4,3] ,I am getting DSL as output.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Change the data type of this field in the Sequential File stage from Date to VarChar(10) or Char(10). You can then extract the day number and month name using Field() function (especially if the day number may contain one or two digits) or substring (if the day number always contains two digits). Convert month name to month number using something like Index() function searching a string containing all twelve month names. For example:

Code: Select all

(Index("JanFebMarAprMayJunJulAugSepOctNovDec",svMonthName,1)+2)/3
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