-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Date Issue in Hibernate Query
PostPosted: Fri Jun 01, 2007 6:10 am 
Newbie

Joined: Fri Jun 01, 2007 6:04 am
Posts: 4
Hi Frnds,

In my code the query is generated like this...

select * from TableA where currDate = 'Fri Jun 01 14:47:45 IST 2007'

I'm using java.util.Date in my code.But the database(MySQL) has different Date format like '2007-06-01 14:47:45'.

So obviously my query doesn't return the correct result. Can you suggest How to solve this problem?

Thanks in Advance,
Senthil.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 01, 2007 12:27 pm 
Beginner
Beginner

Joined: Thu Apr 12, 2007 10:43 am
Posts: 21
Location: Brazil
Hi Senthil,

Is [currDate] a DATE column or a CHAR column? If it's a CHAR column, format your java.util.Date parameter with SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format() and pass the formatted string to the Query. If it's a DATE column things are a bit easier, just pass the java.util.Date object to the Query and you're set. Cheers,

Roger


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.