Solved

display days that have a specific month !!

Posted on 2002-04-06
14
214 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
Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tagging and Merging on Branch 1 70
glassfish admin console 1 53
Setup GlassFish 4 57
program arguments vs VM arguments 4 60
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

710 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