Page 1 of 1

Converting string to date in modify stage

Posted: Mon Jun 15, 2009 5:17 am
by shukla_krishna
Hi,

I wanted to convert one varchar field into date field using the modify stage. My input field is in the dd-mm-yyyy format and I used the below specification in the modify stage.

in_col:date = date_from_string "%dd-%mm-%yyyy"(in_col)

But I am getting the below error while running the job.

main_program: Error parsing modify adapter: Expected ';' or end, got: "%dd-%mm-%yyyy""
Expected destination field selector, got: ")"; input:
Dt_of_extrcn:date = date_from_string "%dd-%mm-%yyyy"(Dt_of_extrcn)
;


Please help me to resolve this issue.

Thanks

Posted: Mon Jun 15, 2009 5:51 am
by sambarand
Try using this :

Dt_of_extrcn:date = date_from_string(Dt_of_extrcn)

Make sure the input data type is of Varchar and output data type is Date for this column .

Re: Converting string to date in modify stage

Posted: Mon Jun 15, 2009 6:00 am
by shukla_krishna
Thanks Sam. It works.

But my input data is in the format dd-mm-yyyy. Can I convert a string in the format dd-mm-yyyy to date field.

Posted: Mon Jun 15, 2009 4:11 pm
by ray.wurlod
What is your default date format string? It is is not "%dd-%mm-%yyyy" then you need to specify the date format string - inside square brackets - in the Specification in the Modify stage.

Code: Select all

date_from_string[%dd-%mm-%yyyy](inputcolumn)
Note also that this will not work if your date is not precisely this format, for example 16/6/2009 or 16-6-2009 or 16/06/2009 will not work, but 16-06-2009 will.