How to handle two different date formats in same column?

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
BMSK
Participant
Posts: 41
Joined: Wed Feb 06, 2008 7:00 am
Location: Bangalore

How to handle two different date formats in same column?

Post by BMSK »

Hi all,

My input file contains date column.
In this date is coming in the format yyyymmdd and ddmmyyyy format.

But I want to do the date validation and convert into String.

for that I am using valid function and StringToDate( "DateColumn", "%yyyy%mm%dd") But how to handle ddmmyyyy fromat.

thanks
BMSK.
mavrick21
Premium Member
Premium Member
Posts: 335
Joined: Sun Apr 23, 2006 11:25 pm

Post by mavrick21 »

Can you filter them into two separate links based on a flag in each record? Then it would be easier to do the validation.

I don't think there is any other way to handle this scenario but I might be wrong.
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

No need to split into separate links. This can be done within a single transformer.

Look at the 5th and 6th digits of the incoming date. If the value is not that of a valid month (01-12), then you are seeing the second format (ddmmyyyy) and can validate against that. Otherwise, you are seeing the first format (yyyymmdd) and can validate against it.

If date[5,2] > '12' then validate/convert ddmmyyyy else validate/convert yyyymmdd

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Magna Carta was signed on 15 June 1215
:wink:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
BMSK
Participant
Posts: 41
Joined: Wed Feb 06, 2008 7:00 am
Location: Bangalore

Post by BMSK »

Hi ray,

Please let me know the solutions from your side.

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

Post by ray.wurlod »

Until you can document a business rule that unambiguously can identify dates of different formats (such as how James suggested) there's nothing more I can add. 12150615 and 15061215 are both valid, but maybe your data don't deal with dates that old.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

ray.wurlod wrote:Magna Carta was signed on 15 June 1215
:wink:
And thus began DataStage 0.01...
- james wiles


All generalizations are false, including this one - Mark Twain.
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

jwiles wrote:
ray.wurlod wrote:Magna Carta was signed on 15 June 1215
:wink:
And thus began DataStage 0.01...
Datastage 0.01 to Datastage 8.5 took 800 years. Change in each version took 100 years :) :wink:
Post Reply