Routine to get month-enddate

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
sdfasih
Participant
Posts: 39
Joined: Wed May 24, 2006 7:22 pm

Routine to get month-enddate

Post by sdfasih »

Hi,
I would like to have a routine that will return a monthenddate for a given date.date is in yyyy-mm-dd format.
Thanx .
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Here's the trick. Write a function to take a date YYYY-MM-DD, add one to the month and allow for going over 12, then use the ICONV function to make the date the internal integer value. Subtract one from that value and then use OCONV to reformat the date. You will now have the last day of the month for your given date and because you used ICONV and OCONV those functions have accommodated leap years and days-in-a-month discrepancies.
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
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: Routine to get month-enddate

Post by gateleys »

sdfasih wrote:Hi,
I would like to have a routine that will return a monthenddate for a given date.date is in yyyy-mm-dd format.
Thanx .
You could use MONTH.LAST with MONTH.TAG (in yyyy-mm format) as input. Use the conv brothers to get the output in desired format. FYI, it is available in DSTransforms\Built-in\Dates.

gateleys
Post Reply