can't read date column from excel sheet

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
h4harry1
Participant
Posts: 16
Joined: Sat Mar 19, 2011 8:01 am

can't read date column from excel sheet

Post by h4harry1 »

Hi All,

I have an excel sheet, in this sheet i have a date column, i am trying to fetch the data from this sheet and storing this is db2 database. I have a problem in this , some of the dates in excel sheet are:-
1. written as 0
2. written in the format as mm/dd/yyyy.
3. written in the format m/dd/yyyy
4. written in the format as mm/d/yyyy.

In the transformer stage i have given the following condition for date column:-

if DSLink36.END_DATE_01='0' then SetNull() else StringToDate(DSLink36.END_DATE_01,"dd/%mm/%yyyy")

This works fine if the date is 0 or in the format of mm/dd/yyyy.

But it gives run time error when trying to process the date which is in the format of m/dd/yyyy, mm/d/yyyy etc. Here i understand the problem , which is it expects 2 digits for day, 2 digits for month and four digits for year , but don't know how to solve it.

any help is appreciated.

Thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You need to ensure that each 'segment' of the date is the correct number of digits as you've found. That means breaking it up, padding the ones that need a leading zero, putting it back together and then calling the function. That or enforce a Date format in the spreadsheet that lets you not need to do that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ds@tcs
Participant
Posts: 24
Joined: Thu Mar 17, 2011 6:26 am
Location: chennai
Contact:

Post by ds@tcs »

Use transformer stage, in the transformer use day from date and month from date , then which rows r having single char date or month for that rows add 0, then gain conver to date , try this..
Regards
Sankar
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

How about a format string of "%m/%d/%yyyy"? %m and %d will handle either 1 or 2 digit values, as is indicated in the product documentation "Parallel Job Developer Guide".

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hmmm... based on the advice I've seen given out over the years, I'm thinking the documentation may be incorrect. That or the advice. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There are variants available, like "%(m,v)/%(d,v)/%yyyy", at least in version 8.5.
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