Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8538011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:02:35+00:00 2026-06-11T11:02:35+00:00

I have a table in MySQL server called Caller_List. In this table I have

  • 0

I have a table in MySQL server called Caller_List. In this table I have a single date column called call_date whose data type is Date. I have created a web page in which I have a SELECT Box for from_day (where all days 1 to 31 are stored), a SELECT box for month (where all month names from January to December are stored), a SELECT box for year (where all years from 2000 to 2012 are stored. Like I also have a SELECT box for to_day, to_month and to_year.

The problem is when I fetch these day,month and year from java servlet using request.getParameter() method, it is fetched as string data type and stored in variable called from_date and to_date. I concatenate from_day,from_month and from_year and store in the variable called from_date. Also I concatenate to_day,to_month and to_year and store in to_date. I concatenate them in the format year-month-day since MySQL understands this format.

I then pass the following query to retrieve data between these two from_date and two date:

select caller_name,call_date 
from Caller_List 
where call_date>='"+from_date+"' and call_date<='"+to_date+"'

I also tried the following query but in vain:

select caller_name,call_date 
from Caller_List 
where call_date between '"+from_date+"' and '"+to_date+"'

I also came to know that I need to convert from_date and to_date to date format before executing the query. But I am a novice in java, I do not know how to do it. Also I want the date in the format year-month-date. I do want to display time with date, please please help me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:02:36+00:00Added an answer on June 11, 2026 at 11:02 am

    If you only want to know how to parse a String to a Date in java, you could simplely use the SimpleDateFormat class.

    final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    try {
        final Date fromDate = dateFormat.parse(from_date);
    } catch (ParseException e) {
        // ...
    }
    

    Assume that your from_date string is looks like 2012-09-16.

    And if you want to display a date with time. You can also use the SimpleDateFormat.

    final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    try {
        final String displayDate = dateFormat.format(new Date());
    } catch (ParseException e) {
        // ...
    }
    

    The displayDate should looks like 2012-09-16 20:13:25.

    One more thing, you could compare a string type and a date type in MySQL. Just make sure your date string has the pattern “yyyy-mm-dd hh:mm:ss”. Of course, you should use the preparedStatement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my SQL Server database schema I have a data table with a date
Let's say I have a legacy MySQL table called server with fields serverid:integer and
I have a MySQL InnoDB table on a RedHat Enterprise Linux 4 server, and
I have a simple table on my local server. mysql> desc table ; +-------+---------+------+-----+---------+-------+
I have a Money column in my SQL Server 2008 table. In my below
I have this script to output everything from table called Articles. If I load
I am using MySQL Workbench to create a database. I have a table called
I have a table called jobs and I can get data out of the
I have created a survey system using php and mysql. I have a table
I have a mySQL database table setup called site . Rather than qet the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.