StringToDate

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
NigeGriff
Premium Member
Premium Member
Posts: 46
Joined: Mon Nov 24, 2003 5:46 am

StringToDate

Post by NigeGriff »

I'm trying to use StringToDate and generating the followin error message :- 'Conversion error calling conversion routine date_from_string data may have been lost'.

The format is - StringToDate(trim(svTermDate2,' ','A'),"%yyyy-%mm-%dd")

svTermDate2 = svTermDateYYYYMinus1:"-":svTermDateMM:"-":svTermDateDD

svTermDateYYYYMinus1 = YearFromDate(TimestampToDate(T1_Input.TERM_END_DATE)) -1

svTermDateMonth = MonthFromDate(TimestampToDate(T1_Input.TERM_END_DATE))

svTermDateDay= MonthDayFromDate (TimestampToDate (T1_Input.TERM_END_DATE))

svTermDateMM = str('0',2 - len(svTermDateMonth)):svTermDateMonth

svTermdateDD = str('0',2 - len(svTermDateDay)):svTermDateDay

I'm using the str function to add leading 0's to the month and day values output from the MonthFromDate and MonthDayFromDate functions.

When i view the value contained in svTermDate2 as part of an output dataset it looks OK even though the warning message is generated.
Thanks
Nigel
arvind_ds
Participant
Posts: 428
Joined: Thu Aug 16, 2007 11:38 pm
Location: Manali

Post by arvind_ds »

What is the format of your input date.?
Arvind
NigeGriff
Premium Member
Premium Member
Posts: 46
Joined: Mon Nov 24, 2003 5:46 am

Post by NigeGriff »

The input date is TermEndDate and is a timestamp format.
Thanks
Nigel
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Specifically... YYYY-MM-DD HH24:MI:SS? All fields other than year always two digits? You can't do StringToDate() from a full Timestamp, you need to pass it just the date portion.
-craig

"You can never have too many knives" -- Logan Nine Fingers
NigeGriff
Premium Member
Premium Member
Posts: 46
Joined: Mon Nov 24, 2003 5:46 am

Post by NigeGriff »

I am already converting the term_end_date into a date format using TimestampToDate before applying any of the other functions.
Thanks
Nigel
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Just going by what you posted as your first example:

The format is - StringToDate(trim(svTermDate2,' ','A'),"%yyyy-%mm-%dd")
-craig

"You can never have too many knives" -- Logan Nine Fingers
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

How many rows are you sending through and how many warning messages are you getting? Refine your input until you can work out which record is giving the warning.

Then send all your stage variables to an output stream (concatenate within quotes or brackets so you can see the full string of each). If issue still not obvious, post your source and stage variable values here.
Post Reply