String to Date - Format issue

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
balu536
Premium Member
Premium Member
Posts: 103
Joined: Tue Dec 02, 2008 5:01 am

String to Date - Format issue

Post by balu536 »

Hi,
I need to convert incoming String to Date. The format of the string is "Month dd, yyyy" Ex: (November 29, 2012).

I used below function and job got aborted with error " Invalid type: November 29, 2012."

StringToDate(Input Column,"%mmmm %dd, %yyyy").

Please help on this.
balu536
Premium Member
Premium Member
Posts: 103
Joined: Tue Dec 02, 2008 5:01 am

Post by balu536 »

The issue was with IsValid function. Ran to success after making below change

Before:
IF
IsValid(Source, "%mmmm %dd, %yyyy")
THEN
StringToDate(Source,"%mmmm %dd, %yyyy") ELSE SetNull()

After:
IF
IsValid("date",Source, "%mmmm %dd, %yyyy")
THEN
StringToDate(Source,"%mmmm %dd, %yyyy") ELSE SetNull()
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Right. You need to tell it what kind of validation it needs to do. And don't fall into the trap of thinking you can use IsValidDate instead. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply