Find the last day of the 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
kamesh_sk
Participant
Posts: 43
Joined: Fri May 27, 2005 7:58 am

Find the last day of the month

Post by kamesh_sk »

Hi ,

Can anyone help me to find out the DS function to find the last day of the given month.i have one function called month.last from the built in transforms. so this will give me the internal format for the last day of the month whch i have supplied in the format yyyy-mm. Example: MONTH.LAST("1993-02") => 9191,
where 9191 is the internal representation of February 28, 1993...now i need a oconv function to convert this 9191 and get the date only.....can anyone help ...Thanks in advance
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Hint: Get the first day of the following month in internal format, then subtract one from it to get the last day of the prior month.
kamesh_sk
Participant
Posts: 43
Joined: Fri May 27, 2005 7:58 am

Post by kamesh_sk »

ArndW wrote:Hint: Get the first day of the following month in internal format, then subtract one from it to get the last day of the prior month. ...

Can you kindly explain this with an example
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The internal date of the last day of the month of February 2008 is

Code: Select all

ICONV('2008-03-01","D4-YMD[4,2,2]")-1
. You didn't specify if you wanted a full date, a day-of-the-week, a day-number in month or another format as output so I can't suggest any OCONV() function to use, but all the options are well-documented in the BASIC Programmer's Guide
kamesh_sk
Participant
Posts: 43
Joined: Fri May 27, 2005 7:58 am

Post by kamesh_sk »

ArndW wrote:The internal date of the last day of the month of February 2008 is

Code: Select all

ICONV('2008-03-01","D4-YMD[4,2,2]")-1
. You didn't specify if you wanted a full date, a day-of-the-week, a day-number in month or another format as output so I can't suggest any OCONV() function to use, but all the options are well-documented in the BASIC Programmer's Guide
sir,

My requirement is to check whether the date which i receive in a business date column is the last day of that particular month specified in the data.
For ex if i get a January month data , then the business date must be 31-01-2008..... so i need to check whether the given date is last date of the month jan and so on for other months also........so i was trying to figure out some solution for this.....can you kindly help
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

If "OCONV(ICONV(YourDate,YourDateFormat)+1,'DD')=1" then YourDate is the last day of the month.
kamesh_sk
Participant
Posts: 43
Joined: Fri May 27, 2005 7:58 am

Post by kamesh_sk »

ArndW wrote:If "OCONV(ICONV(YourDate,YourDateFormat)+1,'DD')=1" then YourDate is the last day of the month. ...
Sir,

I tried this "OCONV(ICONV(YourDate,yyyymmdd)+1,'DD')=1" then the output is 1 and when i try with -1 then it is 30 ,,,and even when i change my month to Aug and with -1 it still gives 30...Afraid the code is not working properly......kindly help
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Post by thurmy34 »

Hi
You can try this YOURDATE=MONTH.LAST(YOURDATE).
The format of YOURDATE is DMY[2,2,4] in my case.
Hope This Helps
Regards
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Close. The MONTH.LAST transform returns an internal date and expects the input as YYYY-MM. But you are correct that you can compare a date to this date and see if they match, as long as you've prepared both properly.
-craig

"You can never have too many knives" -- Logan Nine Fingers
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Post by thurmy34 »

Hi
You are right Chulet , i missed a step in my job.
I convert a date to YOURDATE with

Code: Select all

 Oconv(de_table_pce.D_TRAITEMENT,"D/DMY[2,2,4]")
then i place this constraint to select the rows i want

Code: Select all

de_table_pce.D_TRAITEMENT=MONTH.LAST(YOURDATE [7,4]:'-':YOURDATE [4,2])
Hope This Helps
Regards
Post Reply