handle 'm/d/yyyy' and 'mm/dd/yyyy'

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
getsatish_gk
Participant
Posts: 104
Joined: Sat Dec 24, 2005 1:26 am
Location: Bengaluru

handle 'm/d/yyyy' and 'mm/dd/yyyy'

Post by getsatish_gk »

I have a date field in string format from the input link.. values could be in format 'm/dd/yyyy' or 'mm/d/yyyy' i.e, ex: '1/28/1992'.or '01/8/1992'

I am using below function to handle it
StringtoDate(Input_Link.Column,"%m/%dd/%yyyy") but this works only for 'm/dd/yyyy' input dates

Please suggest a common way to handle this...
appending '0' in single digit date/month from source is my last option

Thanks!
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Search the Parallel Job Developer's Guide manual for "Date and Time Formats" (in Chapter 2). The part about variable forms follows the main table of string format components.

Code: Select all

"%(m,s)/%(d,s)/%yyyy"
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
getsatish_gk
Participant
Posts: 104
Joined: Sat Dec 24, 2005 1:26 am
Location: Bengaluru

Post by getsatish_gk »

Thanks ray, I did refered this and using this
StringtoDate(Input_Link.Column,"%(m,s)/%(d,s)/%yyyy")) this should handle single and double digits of DAY and MONTH.. but still I'm having this warning in the log

Invalid date value in getInputFieldAsDate() for field '0' of input dataset '0'.


Please suggest.
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

What is the invalid date's actual value? Are you getting any records with 3 digit days or months, 5 digit years, etc.?
Choose a job you love, and you will never have to work a day in your life. - Confucius
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As noted, sounds like you are getting bad date values. You might want to use an IsValid check before you do the conversion and only convert good dates.

Funny, saying "bad dates" always makes me think of Indiana Jones and that poor monkey. Ok, maybe not all that funny.
-craig

"You can never have too many knives" -- Logan Nine Fingers
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

If the incoming value were 12/33/2013, it should flag it as an invalid date. Try adding a reject to route the invalid date values for review.

If you anticipate an upcoming bad date, you may want to propose to meet on an invalid date.
Choose a job you love, and you will never have to work a day in your life. - Confucius
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If your file has column headings and your Sequential File stage has "First line is column headings" set to False, the column heading itself will generate an invalid value.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply