given a date (say, 09/14/2005),
1. how to compute end of the month?
2. how to add/subtract 9 months from the above end of month?
Suppose, another date (say, 01/19/2005) is also given, how to compute the number of weeks between the two dates?
END-OF_MONTH, ADD_MONTHS, NUM_OF_WEEKS
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Welcome aboard! :D
Start by reviewing Transforms such as MONTH.LAST, MONTH.FIRST and so on.
Then search the forum for suggestions.
Get back if you're still struggling.
Adding weeks is easy. It's adding (7 * days). Since dates are stored internally as days (search for Iconv() function), this is simple arithmetic in DataStage.
Start by reviewing Transforms such as MONTH.LAST, MONTH.FIRST and so on.
Then search the forum for suggestions.
Get back if you're still struggling.
Adding weeks is easy. It's adding (7 * days). Since dates are stored internally as days (search for Iconv() function), this is simple arithmetic in DataStage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
HI,ray.wurlod wrote:Welcome aboard! :D
Start by reviewing Transforms such as MONTH.LAST, MONTH.FIRST and so on.
Then search the forum for suggestions.
Get back if you're still struggling.
Adding weeks is easy. It's adding (7 * days). Since dates are stored internally as days (search for Iconv() function), this is simple arithmetic in DataStage.
how about adding months including leap year constraints
![Rolling Eyes :roll:](./images/smilies/icon_rolleyes.gif)
regards
kumar
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
I have a bulletproof routine for doing that. Anyone who engages my professional services for DataStage is entitled to the suite, which includes AddDays, AddWeeks, AddMonths and AddYears (both to dates and to timestamps), fully documented and tested.
Essentially the algorithm is to add the months, adjusting year if necessary, then rewind the day number until a legal date is encountered. Plus some variation when the offset number is negative. Plus a whole lot of idiot-proofing to take account of invalid input arguments.
Essentially the algorithm is to add the months, adjusting year if necessary, then rewind the day number until a legal date is encountered. Plus some variation when the offset number is negative. Plus a whole lot of idiot-proofing to take account of invalid input arguments.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.