Date Calculation to get the next quarter based on Input 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

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

Post by ray.wurlod »

For one week only, all is revealed!
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post by Titto »

Hi Ray,
ray.wurlod wrote:For small volume of data, a BASIC Transformer stage could serve here. Use

Code: Select all

Oconv(Iconv(TheDate, "D"), "DQ")
to generate the quarter number (1, 2, 3 or 4). Then take the remainder after dividing the quarter number into the month number, added to the month number. Use the Mod() function to get the remainder after integer division.

For larger volumes use a lookuptable in the Modify stage (function lookup_int16_from_string or lookup_string_from_int16 for example) to convert the month number to a quarter number. Then proceed as above in a Transformer stage. Or build the lookup as a delimited string "1,1,1,2,2,2,3,3,3,4,4,4" in a stage variable in a Transformer stage and use the Field() function to extract the appropriate quarter based on the month number then again proceed as above.
I was wondering - for the first part i can't use that in PX. But could you please dirve me using an example.

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

Post by ray.wurlod »

You CAN use it in PX, via a BASIC Transformer stage.
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