String to Date fatal error

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
devesh_ssingh
Participant
Posts: 148
Joined: Thu Apr 10, 2008 12:47 am

String to Date fatal error

Post by devesh_ssingh »

Hi,

i have searched the forum regarding this error but nothing worked for me

i have input col
Enroll_DT char(26)
UNenroll_DT char(26)

target is
Enroll_DT date(10)
UNenroll_DT date (10)

i have getting error Fatal Error: Invalid Julian day

the input value is
ENROLL_DT:2010-09-02-17.09.46.399604
UNENROLL_DT:2010-09-03-02.04.33.042327
also some values are like
UNENROLL_DT:0000-00-00


i have used folloeing derivation

StringToDate(lnk_Fnl_out.ENROLL_DT[1,10],"%yyyy-%mm-%dd")
StringToDate(lnk_Fnl_out.UNENROLL_DT[1,10],"%yyyy-%mm-%dd")

did n't worked out then
If TrimLeadingTrailing(lnk_user_dataset.UNENROLL_DT)='' Then StringToDate('0000-00-00',"%yyyy-%mm-%dd") Else StringToDate(lnk_user_dataset.UNENROLL_DT,"%yyyy-%mm-%dd")

nothing worked out :cry:

please let me know if any one can help me to sort this :)

Thannks
Devesh
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Do you want it converted into Date or timestamp?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
devesh_ssingh
Participant
Posts: 148
Joined: Thu Apr 10, 2008 12:47 am

Post by devesh_ssingh »

date(10)
Etler21
Participant
Posts: 52
Joined: Mon Mar 08, 2010 5:51 am

Something like this should work fine

Post by Etler21 »

StringToTimestamp((lk_read.sheet[1,4]:'-':lk_read.sheet[5,2]:'-':lk_read.sheet[7,2]) : "-" : "00" :"." : "00" :"." : "00" )
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What is your target database? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
devesh_ssingh
Participant
Posts: 148
Joined: Thu Apr 10, 2008 12:47 am

Post by devesh_ssingh »

hey craig...

its Db2..
devesh_ssingh
Participant
Posts: 148
Joined: Thu Apr 10, 2008 12:47 am

Post by devesh_ssingh »

@Etler21
i need to convert string to date, not timestamp..

as i said how do i tackle somthing 0000-00-00 comming from source....
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Take the first 10 characters from you input data and grind it through the StringToDate() function.
For input anomalies like '0000-00-00', get the business rule and apply accordingly.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I thought (from other posts here) that DB2 wanted dates in internal format.
-craig

"You can never have too many knives" -- Logan Nine Fingers
devesh_ssingh
Participant
Posts: 148
Joined: Thu Apr 10, 2008 12:47 am

Post by devesh_ssingh »

@DSguru,

when i apply buisness rules, used below conditions


If TrimLeadingTrailing(lnk_user_dataset.ENROLL_DT) = '0000-00-00' Or TrimLeadingTrailing(lnk_user_dataset.ENROLL_DT) = '' Then StringToDate('0001-01-01',"%yyyy-%mm-%dd") Else StringToDate(lnk_user_dataset.ENROLL_DT,"%yyyy-%mm-%dd")

but i am getting lot of warnings like

"Conversion error calling conversion routine date_from_string data may have been lost "

any suggestion to derive buisness rule so can avoid such error.

thanks
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

chulett wrote:I thought (from other posts here) that DB2 wanted dates in internal format.
Thats true for server. For px it has to be a date.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

devesh_ssingh wrote: If TrimLeadingTrailing(lnk_user_dataset.ENROLL_DT) = '0000-00-00' Or TrimLeadingTrailing(lnk_user_dataset.ENROLL_DT) = '' Then StringToDate('0001-01-01',"%yyyy-%mm-%dd") Else StringToDate(lnk_user_dataset.ENROLL_DT,"%yyyy-%mm-%dd")
I dont see you substring'ing the first 10 characters any where in that statement above????
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

DSguru2B wrote:
chulett wrote:I thought (from other posts here) that DB2 wanted dates in internal format.
Thats true for server. For px it has to be a date.
Ah... thanks.
-craig

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