Solved

display days that have a specific month !!

Posted on 2002-04-06
14
215 Views
Last Modified: 2013-11-24
suppose i have table that contains days
like 26-01-1979 and i want to display all the days that
have the same month and year .

for example :12-01-1979 , 04-01-1979
by using sql command and java servlet
0
Comment
Question by:star5
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 2
14 Comments
 
LVL 3

Expert Comment

by:msterjev
ID: 6923513
SELECT * FROM Table1 WHERE day LIKE '%-01-1979'

Build this string dinamically!
0
 

Author Comment

by:star5
ID: 6923574
this is fixed !!
SELECT * FROM Table1 WHERE day LIKE '%-01-1979'

the day should be entered by the user
into two texts: one holds the month ,the other holds the year
0
 
LVL 3

Expert Comment

by:msterjev
ID: 6923584
I don't understand your comment.Did I answer your question. Where are the points?
0
RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

 

Author Comment

by:star5
ID: 6924080
no u didn't answer the Question,
what u are suggesting is for fixed day
the day should be a variable that can be entered by the user.
the user enter the name of the month in a text and the year in another text

SELECT * FROM Table1 WHERE day LIKE 'user entered day'

0
 
LVL 3

Expert Comment

by:msterjev
ID: 6924622
String month=Request.getParameter("month");
String day=Request.getParameter("year");
String sqlString="SELECT * FROM Table1 WHERE day LIKE '%-"+month+"-"year";
0
 

Author Comment

by:star5
ID: 6924861
are sure about this code
String sqlString="SELECT * FROM Table1 WHERE day LIKE '%-"+month+"-"year";

i think there is a mistake in the quataion marks ""
would u check it please ,
i think it well work
0
 
LVL 3

Expert Comment

by:msterjev
ID: 6924939
String sqlString="SELECT * FROM Table1 WHERE day LIKE '%-"+month+"-"year'";
0
 
LVL 3

Expert Comment

by:msterjev
ID: 6924944
0
 

Author Comment

by:star5
ID: 6927376
not working
0
 

Author Comment

by:star5
ID: 6927393
it gives errors
0
 
LVL 1

Expert Comment

by:jose_tijo
ID: 6927489
String month=Request.getParameter("month");
String day=Request.getParameter("year");
String sqlString="SELECT * FROM Table1 WHERE day LIKE '%-" + month + "-" + year;
0
 

Author Comment

by:star5
ID: 6927893
not working jose_tijo it shows an error .
some missing Quationts or apostofe
0
 
LVL 1

Accepted Solution

by:
jose_tijo earned 5 total points
ID: 6927908
Hi

Try this star5

String month=Request.getParameter("month");
String day=Request.getParameter("year");
String sqlString="SELECT * FROM Table1 WHERE day LIKE '%-" + month + "-" + year + "'";

Tijo
0
 

Author Comment

by:star5
ID: 6928017
when i used :
int month=9;
int year=2001;
   
strSQL="SELECT * FROM Training WHERE startdate LIKE '"+month+"/"+"%"+"/"+year+"'";

it works correctly
note :i'm using doget


but when i tried to read the values from an html page
it shows errors, the html page has method = post

int month;
int year;
month = req.getParameter(month);  
strSQL="SELECT * FROM Training WHERE startdate LIKE '"+month+"/"+"%"+"/"+year+"'";

what is wrong with this
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A solution for Fortify Path Manipulation.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This video teaches viewers about errors in exception handling.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question