Link to home
Start Free TrialLog in
Avatar of kotakinabalu
kotakinabalu

asked on

Q for TimYates/Ken/kludeep

I am following ChainReaction's q previously and i fee curious and try it out my own. Yet, i found the same error like he did... and it's not good for me to tap into his question.. hope 3 of us can help me as well...

ha..

I have create the same DB he have, Access, with Date(InsDateA) and datatye is date.
this is my code:


   PreparedStatement ps = conn.prepareStatement( "SELECT * FROM PURCHASE WHERE "+
    " (ExpDateA > ? AND ExpDateA < ?)" ) ;  
 
   ps.setDate( 1, new java.sql.Date( sdf.parse( startdate ).getTime() ) );
   ps.setDate( 2, new java.sql.Date( sdf.parse( enddate ).getTime() ) );

rs=ps.executeQuery();
int counter=0;
while (rs.next()){
    counter++;
    out.println("<BR>");
out.println(counter + ":"+ rs.getString("Customer") + vf.format(rs.getDate("ExpDateA")));
vf.format(rs.getDate("ExpDateB")) );
    out.println("<BR>");

this is the rawdata.
ExpDateA
11/27/2004
11/26/2005
11/20/2003
12/18/2003
11/24/2003

And this is my result page:

Start Date : 01/11/2003 End Date : 30/11/2003

1:AGNES TAN27/11/2004

2:KIMURA20/11/2003

3:KAWASKI24/11/2003

4:NAKATA18/12/2003

ha.. the first data shouldnt come out.. but i couldn't notice what went wrong... i did try whay TimeYates explain to Chainreaction, but i think i have the same problem with him... :-)

if i change the query again...
Start Date : 01/11/2003 End Date : 15/11/2003

1:KIMURA20/11/2003

2:KAWASKI24/11/2003

3:NAKATA18/12/2003

Again... all the the data is wrong...
:-(
Can guide me as well?
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

What do you get typing this query straight into access?

You sure your field is set up as a "Date" field?
Yeah now the best thing for me is to do it all by myself and test it out...:-)
But its late here and I got my Bday to celebrate so I gonna look into it tommorow... Till then...
have a good time...
Avatar of kennethxu
kennethxu

>> I have create the same DB he have, Access, with Date(InsDateA) and datatye is date.
could you make sure that ExpDateA is also date type?
>>as I told you, forget about the "format" in database, only stay with the format you use in JSP.

This is the best i can share with you........ from ken..
kuldeep, HAPPY BIRTHDAY TO YOU!!!!
oh, it's kuldeep's birthday? my I join the party? Happy Birthday! kuldeep!
Woo

*puts on hat*

Happy birthday!! :-)

Tim
what about a small gift? points to kuldeep!
ASKER CERTIFIED SOLUTION
Avatar of Kuldeepchaturvedi
Kuldeepchaturvedi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kotakinabalu

ASKER

ha.. kludeep, in fact i am waiting for you to come back here to "feel" the warmest of this peoples...

yeah.. my error sovled also...

Thank you to all of you...

:-)
Thank you all for your wonderfull wishes and for points too....:-)
anybody interested in riddles go to www.riddleplanet.com and when you crack the second riddle of second round in contest 2.. then do let me know...
Its stumping me for good 5 days....

cheers
I think it's nearly half day after you post the riddles link, I'm now on 2.1.16, I'm afraid I don't have enough time to carry on but enjoyed. :-)