Creating a Stage variable to convert date

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
pebbles
Participant
Posts: 15
Joined: Wed Oct 24, 2007 7:54 am

Creating a Stage variable to convert date

Post by pebbles »

I need to convert dates from an input data to the last day of the next month in a transformer stage and need help with how to achieve this.
Ernest A
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

A Time dimension would help out.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
pebbles
Participant
Posts: 15
Joined: Wed Oct 24, 2007 7:54 am

Post by pebbles »

Do you mean a time dimension table?
Ernest A
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

yes
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
pebbles
Participant
Posts: 15
Joined: Wed Oct 24, 2007 7:54 am

Post by pebbles »

Ok, thanks.
I was thinking there was a chance this could be achieved in datastage :o
Ernest A
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Nobody suggested that it couldn't be done in a DS transform. The algorithm is to compute the first day of the month that is 2 greater than the current, then to subtract one day from it.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

To find the last day of a month, you can always go to the first day of the next month and then subtract one day (using an inherent date manipulation function, not your own).

There is always a way, but is there a good way? Anytime you are tasked with finding the last day of any month you have to write logic that is month and leap year sensitive. Anytime you have to do something like that then you have to do careful math. If you use inherent functions within a programming language that insulates you from those considerations then the odds of you doing correct math go up.

Time dimensions are just an elegant solution.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
pebbles
Participant
Posts: 15
Joined: Wed Oct 24, 2007 7:54 am

Post by pebbles »

Thanks for this, this really helps.
Ernest A
Post Reply