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
syam
Participant
Posts: 10
Joined: Wed Nov 29, 2006 5:03 am

Date conversion

Post by syam »

Hi All,

Please help how to convert string to date in PX

Ex. 20061122 to 11/22/2006


thanks in advance
SHYAM
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Oddly enough, the StringToDate function. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ajith
Participant
Posts: 86
Joined: Thu Nov 10, 2005 11:10 pm

Post by ajith »

chulett wrote:Oddly enough, the StringToDate function. :wink:
That hits the bull's eye
chandra
Participant
Posts: 88
Joined: Sun Apr 02, 2006 6:50 pm
Location: India

Post by chandra »

U can do with concatinate and substring !
chandra ,
Hyd
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Wrong! Substring and concatenate does not produce a date, it produces a string.

Stop thinking like a server job developer!
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chandra
Participant
Posts: 88
Joined: Sun Apr 02, 2006 6:50 pm
Location: India

Post by chandra »

Thanks !!!
chandra ,
Hyd
ds_developer
Premium Member
Premium Member
Posts: 224
Joined: Tue Sep 24, 2002 7:32 am
Location: Denver, CO USA

Post by ds_developer »

I don't know about Date fields, but I know you can substring and concatenate a Timestamp field for Oracle. I assume it is a string as Ray says, then the Oracle Enterprise stage converts it as needed.

John
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

John - this is a PX subject - so the typical server conversions won't work and you should explicitly convert datatypes and this is what Ray has pointed out.
ds_developer
Premium Member
Premium Member
Posts: 224
Joined: Tue Sep 24, 2002 7:32 am
Location: Denver, CO USA

Post by ds_developer »

You might have to explain this further - I understand this is a PX topic. This is what I am doing in a derivation:

Code: Select all

IF ValidDateOpen = '0' THEN SetNull() ELSE ValidDateOpen[1,4] : '-' : ValidDateOpen[5,2] : '-' : ValidDateOpen[7,2] : ' 00:00:00'
ValidDateOpen is a VarChar stage variable that verifies that the date is valid. The derivation is in a Timestamp field. Maybe the underlying data type is string as Ray points out, but the Oracle Enterprise stage eventually gets it to a date.

It may be this isn't the best way to do it, but it is working. Could it be a version issue? I'm on 7.5.1.A Enterprise Edition.

John
Post Reply