aspose file tools*
The moose likes JDBC and the fly likes How to extract current month and year's records alone Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to extract current month and year Watch "How to extract current month and year New topic
Author

How to extract current month and year's records alone

Ramesh Lakshmanan
Greenhorn

Joined: Oct 14, 2002
Posts: 21
Hi All,
Can anyone let me know , how to fetch the current month and years records alone from an Table.(my database is Oracle).

Here are the sample of records:
TSKID TSTAMP
T1 20-MAR-2002
T2 21-JAN-2003
T3 22-MAR-2001
T4 23-APR-2003
T5 12-MAR-2001
T6 27-MAR-2000
T7 12-MAR-2002
T8 09-APR-2003
T9 08-APR-2003
T10 22-MAR-2003
T11 23-MAR-2003
T12 24-JAN-2003
so i want to take all the TSKID where TSTAMP is ar are current month and year.
Looking forward your reply.
thanks
Ramesh


SCJP1.2,SCWCD<br />SAP/J2EE Consultant<p><br />"Plan for the Work and Work for the Plan."
Michael Zalewski
Ranch Hand

Joined: Jun 10, 2002
Posts: 30
Check out the TO_CHAR function
Michael Zalewski
Ranch Hand

Joined: Jun 10, 2002
Posts: 30
Actually, if you want to just retrieve all the rows where tstamp is in a particular month, it's pretty easy. For example, to retrieve everything from December 2002 through February 2003, just use
Ramesh Lakshmanan
Greenhorn

Joined: Oct 14, 2002
Posts: 21
Hi Guys,
I got the solution.

I think we can use any of the following.Both gave correct result for me.
1> select tskid from TASKTBL where tstamp >= trunc(sysdate,'MM')2> select tskid from TASKTBL where to_char(tstamp,'MON-YYYY') = to_char(sysdate,'MON-YYYY')

thanks
Ramesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to extract current month and year's records alone
 
Similar Threads
Record selection based on current month and year
GregorianCalendar object
Using SpringSource's Jasper within OSGi (moving from Spring Web Extender to HTTP Service)
how to display all months of a particular year according to the following rule
Method to sort by month