Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Obtain last day of next month
Goto page Previous  1, 2
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
Author Message
dbzTHEdinosauer

Senior Member


Joined: 20 Oct 2006
Posts: 1641
Location: germany

PostPosted: Fri Aug 22, 2008 12:42 am    Post subject:
Reply with quote

This is the Db2 Vsn 7 reason:
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNMCH17/4.21.47?SHELF=&DT=20061207111438&CASE=

This is the DB2 Vsn 8 reason:
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNC1J12/3.20.50?SHELF=&DT=20070111144235&CASE=

This is the Db2 Vsn 9 reason:
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNC1K11/3.21?DT=20070917024311


you can (you should) download the pdf for whichever version your systems running. (the pdf symbol at the upper right of any IBM document is the -download this pdf- button)

Suggest you download so that you can talk to your dba.

If you are running at a site with version 6 or less,
suggest you find a job with another company.
Back to top
View user's profile Send private message
References
aneeta

New User


Joined: 08 Dec 2005
Posts: 44
Location: Chennai

PostPosted: Fri Aug 22, 2008 1:14 am    Post subject: Reply to: Obtain last day of next month
Reply with quote

Hi,
When I try thus query-
SELECT (DATE('2008-08-31') + 1 MONTHS )
FROM SYSIBM.SYSDUMMY1;

I get the result as 2008-09-30

But when I try this query for the next month end,

SELECT (DATE('2008-09-30') + 1 MONTHS )
FROM SYSIBM.SYSDUMMY1;

I get the result as 2008-10-30 instead of 2008-10-31.

Can I get help on this..I am try to complete this with version of DB2 i currently have as I am not able to use LAST_DAY function.

Thanks
Aneeta
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1003
Location: Virginia, USA

PostPosted: Fri Aug 22, 2008 5:47 am    Post subject:
Reply with quote

This will always return the first day of the current month
Code:
SELECT CURRENT DATE - (DAY(CURRENT DATE) - 1) DAYS
FROM SYSIBM.SYSDUMMY1


This will always return the last day of the current month without using the last_day function
Code:
SELECT CURRENT DATE - (DAY(CURRENT DATE) - 1 ) DAYS + 1 MONTHS - 1 DAYS 
FROM SYSIBM.SYSDUMMY1;                                                 


For the last day of the next month without using the last_day function
Code:
SELECT CURRENT DATE - (DAY(CURRENT DATE) - 1 ) DAYS + 2 MONTHS - 1 DAYS 
FROM SYSIBM.SYSDUMMY1;                                                 
Back to top
View user's profile Send private message
dick scherrer

Global Moderator


Joined: 23 Nov 2006
Posts: 8770
Location: 221 B Baker St

PostPosted: Sun Aug 24, 2008 8:47 am    Post subject: Reply to: Obtain last day of next month
Reply with quote

Hi Craig,

Cool icon_smile.gif

I deleted my earlier post about experimenting with some other dates.

Then i thought - will these also work for the earlier releases of db2?

d
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 HoursGoto page Previous  1, 2
Page 2 of 2