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
 

 

Query to pull dates using SQL

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

New User


Joined: 02 Jun 2008
Posts: 48
Location: India

PostPosted: Thu Nov 13, 2008 8:30 pm    Post subject: Query to pull dates using SQL
Reply with quote

Hi all,
can any one suggest me a way to write a single query to pull
1. This month last date,
2. This month first date,
3. Next month first date,
4. Next month last date,
5. Previous month first date,
6. Previous month last date,
7. Last year first date,
8. Last year last date,
9. Next year first date,
10. Next year last date.

Thanks in advance.
Back to top
View user's profile Send private message

Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1228
Location: Israel

PostPosted: Thu Nov 13, 2008 9:51 pm    Post subject:
Reply with quote

1. This month last date: LAST_DAY(CURRENT DATE)
2. This month first date: LAST_DAY(CURRENT DATE - 1 MONTH) + 1 DAY
3. Next month first date: LAST_DAY(CURRENT DATE) + 1 DAY
4. Next month last date: LAST_DAY(CURRENT DATE + 1 MONTH)
...
7. Last year first date: DATE(CONCAT('01.01.',CHAR(YEAR(CURRENT DATE)-1)))
...
10. Next year last date: DATE(CONCAT('31.12.',CHAR(YEAR(CURRENT DATE)+1)))

you will have to fill the missing answers by yourself, it should be easy now...
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Fri Nov 14, 2008 12:31 am    Post subject:
Reply with quote

Sounds like a class assigment. Marso I hope you get credit for the answer.
Back to top
View user's profile Send private message
sant532

New User


Joined: 02 Jun 2008
Posts: 48
Location: India

PostPosted: Fri Nov 14, 2008 12:05 pm    Post subject: Thanks...
Reply with quote

Thanks A lot Marso!
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 Want to pull the job log into a Mainf... Jishu Mukherjee Compuware & Other Tools 9 Tue Mar 21, 2017 4:48 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm


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