getting data for the last three months

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
uzl
Premium Member
Premium Member
Posts: 20
Joined: Mon Jul 23, 2012 4:33 am

getting data for the last three months

Post by uzl »

I have the following requirement. I need to extract data for the last three months. So today (18-06-2013) I have to extract data from 01-03-2013 to 31-05-2013.
I managed to get the enddate : OConv((MONTH.FIRST(MONTH.TAG(DATE()))) ,'D-YMD[4,2,2]') :' ':Oconv(Time(),'MTS.') gives me "2013-06-01 11:13:17.000". My first question is how to transform this to "2013-06-01 00:00:00.000".
My second question is : how do I go three months back ?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

OConv((MONTH.FIRST(MONTH.TAG(DATE()))) ,'D-YMD[4,2,2]') :' 00:00:00'
uzl
Premium Member
Premium Member
Posts: 20
Joined: Mon Jul 23, 2012 4:33 am

Post by uzl »

This solves my first question. I'm a bit embarressed it was so simple :oops: . Now my second question?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

How do you define '3 months back'?

does it mean subtract 90 days? or the first day of the month when you subtract 3 from the current month? Or some other rule?
uzl
Premium Member
Premium Member
Posts: 20
Joined: Mon Jul 23, 2012 4:33 am

Post by uzl »

substract 3 from the current month.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

One last question - you are using OCONV() so I would assume a server job, but the question is posted in the parallel forum. The answer depends upon which you are really using.
uzl
Premium Member
Premium Member
Posts: 20
Joined: Mon Jul 23, 2012 4:33 am

Post by uzl »

It's a server job. We were told only to use serverjobs. We started working with datastage with version 8. I have to admit that I don't understand the distinction between the two fora.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You posted in the EE forum which is dedicated to PX / Parallel jobs and you marked your Job Type as Parallel as well, hence Arnd's question. I'm going to fix both issues. Hang on...

Here we are, correct forum and job type.
-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 »

I suspect the question relates to a sequence governing parallel jobs.

You might like also to investigate using DataStage routines such as the AddMonths routine available here.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
bhasds
Participant
Posts: 79
Joined: Thu May 27, 2010 1:49 am

getting data for the last three months

Post by bhasds »

Hi uzl,

You may use the following to get the 3 month back date-

Code: Select all

'01':"-":(if  DSJobStartTimestamp[6,2] - 3 <10 Then 0:DSJobStartTimestamp[6,2] - 3 Else DSJobStartTimestamp[6,2] - 3):"-":DSJobStartTimestamp[1,4]:'00:00:00'
uzl
Premium Member
Premium Member
Posts: 20
Joined: Mon Jul 23, 2012 4:33 am

Re: getting data for the last three months

Post by uzl »

Thanks bhasds. We use different date-formats but your example has set me in the right direction.

Code: Select all

prepBeginMaand_uv.UV_beginMaand : if DSJobStartTimestamp[6,2]-3 <= 0 then (DSJobStartTimestamp[6,2] + 9) else ('0' : DSJobStartTimestamp[6,2]-3)

prepBeginMaand_uv.UV_beginJaar : if DSJobStartTimestamp[6,2]-3 <= 0 then (DSJobStartTimestamp[1,4] - 1) else DSJobStartTimestamp[1,4]

dateBegin_UV : prepBeginMaand_uv.UV_beginJaar : '-' : prepBeginMaand_uv.UV_beginMaand : '-01 00:00:00.000'
=> the derivation of the year works only for years > 2000
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The AddMonths routine works for any date.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
uzl
Premium Member
Premium Member
Posts: 20
Joined: Mon Jul 23, 2012 4:33 am

Post by uzl »

We don't have experience with added routines. How does this work with upgrades ?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Perfectly. These routines have been in use since version 3.
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