View Single Post
Old 04-08-2008, 07:25 AM   #1 (permalink)
Semolas
Registered User
 
Join Date: Feb 2008
Posts: 25
OS: xp


SQL Statement Help

Hey guys,

I am working on the application to keep track of my finances and do a few other things. I have two tables, Deposits & Withdrawals. Deposits has 3 columns, DATE (an object of type Date -defaults to CURRENT_DATE), WHO_DID (varchar(10) - who made the deposit), and AMOUNT (amount of the deposit - a double). In this program I want to give the user the option to pull up a list of all deposits made in the past 10 days. Off the top of my head I thought it would be something like this:

SELECT * FROM Deposits WHERE DATE >= CURRENT_DATE - 10;

As stuff that I try right off the top of my head is usually wrong, this flopped and said I could not subtract an int from CURRENT_DATE. This wasn't surprising to me. I figured I would do a little digging and find the solution easily. However, I have had trouble finding a solution to this anywhere. It doesn't look like it should be all that difficult to do this. I am using Netbeans that connects to one of their derby databases and using the mysql jdbc to connect to the DB. Any suggestions? Thanks.
Semolas is offline   Reply With Quote