last date of previous month

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
dr46014
Participant
Posts: 59
Joined: Fri Dec 08, 2006 11:09 am
Location: bhubaneswar

last date of previous month

Post by dr46014 »

hi all
can you please tell me the code how to find lastday of previous month in dd-mm-yyyy format
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'm not going to code it all up for you, but here are the steps you'd need to derive that:

* Get current date in any format
* Replace Day # portion with '1'
* Convert to Internal format using IConv
* Subtract 1 from Internal value
* Convert back to External format of choice using OConv

That should be simple enough to build a little routine to do.

:idea: You can also look at the MONTH.LAST transform under the Transforms / Built-In / Dates branch of the Manager for another approach.
-craig

"You can never have too many knives" -- Logan Nine Fingers
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

It always better to search before your post your post.

These posts will help you in achieving what you want.

viewtopic.php?t=102746&highlight=month

viewtopic.php?t=101373&highlight=month

viewtopic.php?t=100700&highlight=month

viewtopic.php?t=91657&highlight=month

Next time, a good search should atleast get you started. :wink:

Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

If you use database stage, you can use last_day() and add_months() function as well.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Post Reply