my dog learned polymorphism
The moose likes JDBC and Relational Databases and the fly likes date wise query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "date wise query" Watch "date wise query" New topic

date wise query


Joined: Jun 07, 2001
Posts: 1
I am using a HTML file in which i getting 6 parameters . 3 for from & 3 for to means month,date & year for from & same for to.means i want to display data like select * from table where dateofbirth falls between from and to..
how i can solve this problem
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Daniel Dunleavy
Ranch Hand

Joined: Mar 13, 2001
Posts: 276
select * from tblname where birthdate > to_date( fromMM | | fromDD | | fromYYYY, 'MMDDYYYY') and birthdate < to_date( toMM | | toDD | | toYYYY, 'MMDDYYYY')
[This message has been edited by Daniel Dunleavy (edited June 07, 2001).]
Wendy Cheong

Joined: Jun 12, 2001
Posts: 7
Just to add on, if u want to do a select from date1 to date2, I think its advisable to store your dates in the following string format in your database : yyyymmdd, eg, 19990101 and 20001212. So, to search for dates between 1/1/1999 and 12/12/2000, all you have to do is to search for strings between 19990101 to 20001212.
It'll also save you some time since all you need to do is to concatenante the year, month and day fields to produce the search string.
Any comments anyone?

------------------------<br />Cheerios,<p>Wendy
I agree. Here's the link:
subject: date wise query
It's not a secret anymore!