Problem in String to 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
jaysheel
Participant
Posts: 57
Joined: Mon Apr 07, 2008 1:54 am
Location: Bangalore

Problem in String to Date conversion

Post by jaysheel »

Hi Experts,

I am trying to convert an input column coming as varchar to Date format.
The input is coming in the format "mm/dd/yy 00:00:0"

I have used the combination of below functions in transformer.

StringToDate(Convert( "0:00:00","", LNK_XFRM_REAL_EST_STORES_DM.store_open_date) ,"%mm-%dd-%yyyy")

and I am getting the column as ******* in peek stage.

And when I am trying to load the database (Netezza) I am gettng the error

main_program: Fatal Error: Added field has duplicate identifier():


I have tried out all possible methods.. Can somebody help me out to get around this.. ?

Thanks in Advance.
- Jaysheel -
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Code: Select all

StringToDate(LNK_XFRM_REAL_EST_STORES_DM.store_open_date[1,8] ,"%mm/%dd/%yyyy")
The important change is in the format mask for the date, the substring is more efficient and versatile than the original convert() function but functionality is the same for your data.
jaysheel
Participant
Posts: 57
Joined: Mon Apr 07, 2008 1:54 am
Location: Bangalore

Post by jaysheel »

Hi,

Thanks for the response. I tried the below code and got same ****** in peek stage.

StringToDate(LNK_XFRM_REAL_EST_STORES_DM.store_open_date[1,8],"%mm/%dd/%yyyy")

Any idea whats wrong happening ?
- Jaysheel -
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

In your case, year is actually two characters long. It should be "yy" rather than "yyyy"

Code: Select all

StringToDate(LNK_XFRM_REAL_EST_STORES_DM.store_open_date[1,8],"%mm/%dd/%yy") 
jaysheel
Participant
Posts: 57
Joined: Mon Apr 07, 2008 1:54 am
Location: Bangalore

Post by jaysheel »

Yes the source data is in the form 'yy'. But i want to convert it to 'yyyy'.
Thats why I have put as 'yyyy'. And I am removing the 00:00:0 part from the source using the function 'convert'. I am banging my head for this since past week. Anybody ever came across such a thing before ?
:(
- Jaysheel -
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The format needs to be that of the source, I should have caught the 4 digit error, sorry. You can then choose your display options for the date elsewhere to display 4 digits.
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

StringToDate() will convert your source to date in the format yyyy-mm-dd automatically. Output it to peek stage to verify the output.
Post Reply