hello everybody,
i'm a new Datastage Developers.
i have a problem.
i explain myself :
i have to integrate one file into a data base.
the file is like it.
article;Qty1;Qty2;Qty3...Qt60
ex :
00001;1;2;3;4....60
the table in the data base is like this.
article - ref_Date - prevision_date - Qty
00001 - 20060523 - 20060529 - 1
00001 - 20060523 - 20060605 - 2
...
ref_Date is sysdate (i do not have any problem with tis)
the prevision_date is the next 60 monday. (one for each column in the file.)
so, my problem is.
how to get the date of the next monday. (the others will be next monday + 7 days...)
i wish you understand my problem.
thanks for your attention.
PS : sorry for my poor english, but i'm french and i do not speak english.
bye.
jerome
function to get the date of the next monday.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The trick you need is to realize that the internal format of dates in server jobs is an integer. If you divide by 7 and take the remainder (the Mod() function), then the result is 0 for Sunday, 1 for Monday, through to 6 for Saturday.
So you take the date (current date is available as system variable @DATE or the Date() function) and do this arithmetic. Add sufficient days to it to get the date of next Monday.Each 1 in the expression represents Monday.
The result is in internal format; use Oconv() or one of the SDK Transforms to generate whatever external date format you require.
So you take the date (current date is available as system variable @DATE or the Date() function) and do this arithmetic. Add sufficient days to it to get the date of next Monday.
Code: Select all
@DATE + (7 - Mod(@DATE,7) + 1 - ((Mod(@DATE,7) <= 1) * 7)
The result is in internal format; use Oconv() or one of the SDK Transforms to generate whatever external date format you require.
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.