aspose file tools*
The moose likes JDBC and the fly likes date problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "date problem" Watch "date problem" New topic
Author

date problem

deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
select item_id,item_name,cus_name,total_cost from purchase where date between ('2/01/2010') and ('10/01/2010')
not giving correct records while i write date ('12/12/2009') and ('19/12/2009')
it gives correct answer

i donot understand the reason for this
i write this query inside jsp page for execute sql query
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
i think this ('2/01/2010') should be ('02/01/2010')


JDBCSupport - An easy to use, light-weight JDBC framework -
deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
i tried this already but it doesnot show correct records.
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
In that case the format is probably wrong. I always used '01.02.2009' instead of the slashes.
deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
if we write between '01/01/2010' and '09/01/2010'
then
it shows records of day 1 to 9 even if they are from any month
while i specify only month january
binu narayanan
Ranch Hand

Joined: Jul 24, 2009
Posts: 56
Check in what format it is stored in your database
deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
format is same in database
dd/mm/yy
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

1) Don't use BETWEEN syntax. It's not great to start with and you have more control with >=, >, <, <=.
2) Use a PreparedStatement so that you never have to worry about date formatting.


My Blog: Down Home Country Coding with Scott Selikoff
deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
it shows records but
problem is that it shows records between two DAYS while
i want records between two DATES
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: date problem