Page 1 of 1

Date conversion

Posted: Mon Nov 05, 2007 11:19 pm
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.

Posted: Mon Nov 05, 2007 11:47 pm
by ArndW
In a transform stage you can use the derivation "In.DateColumn[4,3]" to get "sep" from "29-sep-07"

Posted: Tue Nov 06, 2007 1:53 am
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....

Posted: Tue Nov 06, 2007 2:43 am
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.

Posted: Tue Nov 06, 2007 3:12 am
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....)

Posted: Tue Nov 06, 2007 3:49 am
by ArndW
balu124 - you need to use DSLink17.Call_date[4,3]

Posted: Tue Nov 06, 2007 5:59 am
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.

Posted: Tue Nov 06, 2007 7:06 am
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