Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

To find the previous Month date

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Tue Nov 27, 2007 11:57 am    Post subject: To find the previous Month date
Reply with quote

Hi All,

I need to find the previous month's date, say suppose todays date is 01-01-2008 (1st Jan 2008), My query shd give an output like 01-12-2007, There is an option to get current date from SYSIBM.SYSDUMMY1, am planning to use this query to extract the previous month's date, please let me know the query by which I can do the same. Thanks in Advance

Thamilzan.
Back to top
View user's profile Send private message

prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Tue Nov 27, 2007 12:11 pm    Post subject:
Reply with quote

Hi All,

I think the below query works

SELECT CURRENT_TIMESTAMP - 1 MONTH
FROM SYSIBM.SYSDUMMY1;

please correct me if am wrong

Thamilzan.
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Tue Nov 27, 2007 12:42 pm    Post subject:
Reply with quote

Yes..But it should have been
SELECT DATE(CURRENT_TIMESTAMP - 1 MONTH)
FROM SYSIBM.SYSDUMMY1;
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Tue Nov 27, 2007 12:51 pm    Post subject: Reply to: To find the previous Month date
Reply with quote

Quote:
say suppose todays date is 01-01-2008 (1st Jan 2008), My query shd give an output like 01-12-2007,



I feel that Your "business needs" need better understanding
and the query reviewed accordingly!

working with dates is a murky field!
what if todays date is 31/03/007 ( 31st March 2007 )

I am always amazed by the carelessness with which people
work on dates.....
Back to top
View user's profile Send private message
prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Wed Nov 28, 2007 6:09 pm    Post subject:
Reply with quote

Enrico,

Valid point , but I considered the situation and pls find the query and its o/p below

Code:
select (current_timestamp - 9 month + 1 day) from sysibm.sysdummy1;   
---------+---------+---------+---------+---------+---------+---------+-
                                                                       
---------+---------+---------+---------+---------+---------+---------+-
2007-03-01-13.28.20.151246                                             
DSNE610I NUMBER OF ROWS DISPLAYED IS 1   



and

Code:
select (current_timestamp - 9 month - 1 day) from sysibm.sysdummy1;
---------+---------+---------+---------+---------+---------+-------
                                                                   
---------+---------+---------+---------+---------+---------+-------
2007-02-27-13.32.52.450104                                         
DSNE610I NUMBER OF ROWS DISPLAYED IS 1


The above queery has given the expected value and I believe it should give the 27th of feb 2007 when the foll query is run on 31st march

Code:
Select (current_timestamp - 1 month) from sysibm.sysdummy1;   


Please correct me if am wrong

Thamilzan.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us